1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-13 17:49:10 +00:00

(svn r3496) - Validate filename titles before they get displayed. This avoids crashes with UTF-8 encoded or bad filenames by replacing undisplayable characters with a '?'

This commit is contained in:
2006-01-31 12:08:49 +00:00
parent 822afdcecd
commit 9fd6b1009e
3 changed files with 12 additions and 0 deletions

4
os2.c
View File

@@ -109,6 +109,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
fios->mtime = 0;
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
snprintf(fios->title, lengthof(fios->title), "%s\\ (Directory)", dirent->d_name);
str_validate(fios->title);
}
}
closedir(dir);
@@ -150,6 +151,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
*t = '\0'; // strip extension
ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
str_validate(fios->title);
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
if (strcasecmp(t, ".ss1") == 0 ||
strcasecmp(t, ".sv1") == 0 ||
@@ -236,6 +238,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
fios->mtime = 0;
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
snprintf(fios->title, lengthof(fios->title), "%s\\ (Directory)", dirent->d_name);
str_validate(fios->title);
}
}
closedir(dir);
@@ -276,6 +279,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
*t = '\0'; // strip extension
ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
str_validate(fios->title);
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
mode == SLD_NEW_GAME) {
if (strcasecmp(t, ".sv0") == 0 ||