Fix missing validation on invalid characters in file name (#18287)

When saving a new file with a name containing '/' or '\' on Windows, the incorrect file name would be determined since these characters represent a new folder. This would trigger a failure on save.

The user's input should be validated in all cases. Before, it was only executed for folder names. This change also applies the validation on file names.
This commit is contained in:
Rik Smeets 2022-10-11 13:27:11 +02:00 committed by GitHub
parent 10be64abad
commit 0c78a27d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,7 @@
0.4.3 (in development)
------------------------------------------------------------------------
- Fix: [#14312] Research ride type message incorrect.
- Fix: [#17763] Missing validation on invalid characters in file name.
- Fix: [#17853] Invention name tears while being dragged.
- Fix: [#18064] Unable to dismiss notification messages.
- Fix: [#18070] Underground entrance/exit shows through terrain walls (original bug).

View File

@ -575,16 +575,16 @@ static void WindowLoadsaveTextinput(rct_window* w, WidgetIndex widgetIndex, char
if (text == nullptr || text[0] == 0)
return;
if (!Platform::IsFilenameValid(text))
{
context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE, {});
return;
}
switch (widgetIndex)
{
case WIDX_NEW_FOLDER:
{
if (!Platform::IsFilenameValid(text))
{
context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE, {});
return;
}
const u8string path = Path::Combine(_directory, text);
if (!Platform::EnsureDirectoryExists(path))
{