mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +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:
parent
e58421342c
commit
85ac469458
@ -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…
Reference in New Issue
Block a user