Browse Source

Change sanitization check for `ExportDataAsCode` (#3837)

* Change sanitization check for `ExportDataAsCode`

I opted to use `isalnum` function since it should handle most cases. It
cannot however handle cases of files beginning with numbers.

* Update `ExportDataAsCode` condition

* Reinsert comment on `ExportDataAsCode`
pull/3840/head
Laurentino Luna 8 months ago
committed by GitHub
parent
commit
f0807d2be1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/utils.c

+ 2
- 2
src/utils.c View File

@ -320,8 +320,8 @@ bool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileN
{
// Convert variable name to uppercase
if ((varFileName[i] >= 'a') && (varFileName[i] <= 'z')) { varFileName[i] = varFileName[i] - 32; }
// Replace sa">'-' (non valid character for C identifier with '_')
if (varFileName[i] == '-') { varFileName[i] = '_'; }
// Replace non valid character for C identifier with '_'
else if (varFileName[i] == '.' || varFileName[i] == '-' || varFileName[i] == '?' || varFileName[i] == '!' || varFileName[i] == '+') { varFileName[i] = '_'; }
}
byteCount += sprintf(txtData + byteCount, "#define %s_DATA_SIZE %i\n\n", varFileName, dataSize);

Loading…
Cancel
Save