fix(radio): remove invalid characters from log filenames (#5129)

This commit is contained in:
philmoz
2024-06-06 22:20:25 +10:00
committed by GitHub
parent 8087283b0c
commit 8e64c3bbb1
3 changed files with 28 additions and 28 deletions
+15
View File
@@ -33,6 +33,21 @@
static char _static_str_buffer[32];
static const char s_charTab[] = "_-.,";
const char* sanitizeForFilename(const char* name, int len)
{
strAppend(_static_str_buffer, name, len);
char *s = _static_str_buffer;
// Remove invalid characters in filename
for (int i = 0; s[i]; i += 1)
if (s[i] == '"' || s[i] == ':' || s[i] == '\\' ||
s[i] == '/' || s[i] == '<' || s[i] == '>' ||
s[i] == '?' || s[i] == '*')
s[i] = '_';
return _static_str_buffer;
}
char hex2zchar(uint8_t hex) { return (hex >= 10 ? hex - 9 : 27 + hex); }
char hex2char(uint8_t hex) { return (hex >= 10 ? hex - 10 + 'A' : hex + '0'); }