mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-24 13:52:38 +03:00
[FL-2997] Improve file name filtering #2047
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
84f9af3e7e
commit
c535ce9b76
@ -95,22 +95,17 @@ bool path_contains_only_ascii(const char* path) {
|
|||||||
name_pos++;
|
name_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(*name_pos != '\0') {
|
for(; *name_pos; ++name_pos) {
|
||||||
if((*name_pos >= '0') && (*name_pos <= '9')) {
|
const char c = *name_pos;
|
||||||
name_pos++;
|
|
||||||
continue;
|
|
||||||
} else if((*name_pos >= 'A') && (*name_pos <= 'Z')) {
|
|
||||||
name_pos++;
|
|
||||||
continue;
|
|
||||||
} else if((*name_pos >= 'a') && (*name_pos <= 'z')) {
|
|
||||||
name_pos++;
|
|
||||||
continue;
|
|
||||||
} else if(strchr(" .!#\\$%&'()-@^_`{}~", *name_pos) != NULL) {
|
|
||||||
name_pos++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
// Regular ASCII characters from 0x20 to 0x7e
|
||||||
|
const bool is_out_of_range = (c < ' ') || (c > '~');
|
||||||
|
// Cross-platform forbidden character set
|
||||||
|
const bool is_forbidden = strchr("\\<>*|\":?", c);
|
||||||
|
|
||||||
|
if(is_out_of_range || is_forbidden) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user