UI: Use regexp to filter filename formatting
Avoids unbounded stack growth when pasting content that has many invalid characters. Fixes https://github.com/obsproject/obs-studio/issues/5815.
This commit is contained in:
parent
e58421342c
commit
85ac469458
1 changed files with 8 additions and 7 deletions
|
|
@ -4031,17 +4031,18 @@ bool OBSBasicSettings::AskIfCanCloseSettings()
|
|||
|
||||
void OBSBasicSettings::on_filenameFormatting_textEdited(const QString &text)
|
||||
{
|
||||
QString safeStr = text;
|
||||
|
||||
#ifdef __APPLE__
|
||||
size_t invalidLocation = text.toStdString().find_first_of(":");
|
||||
#elif _WIN32
|
||||
size_t invalidLocation = text.toStdString().find_first_of("<>:\"|?*");
|
||||
safeStr.replace(QRegularExpression("[:]"), "");
|
||||
#elif defined(_WIN32)
|
||||
safeStr.replace(QRegularExpression("[<>:\"\\|\\?\\*]"), "");
|
||||
#else
|
||||
size_t invalidLocation = string::npos;
|
||||
UNUSED_PARAMETER(text);
|
||||
// TODO: Add filtering for other platforms
|
||||
#endif
|
||||
|
||||
if (invalidLocation != string::npos)
|
||||
ui->filenameFormatting->backspace();
|
||||
if (text != safeStr)
|
||||
ui->filenameFormatting->setText(safeStr);
|
||||
}
|
||||
|
||||
void OBSBasicSettings::on_outputResolution_editTextChanged(const QString &text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue