0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

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:
Richard Stanway 2022-01-16 18:33:10 +01:00 committed by Jim
parent e58421342c
commit 85ac469458

View File

@ -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)