Skip to content

Commit 2b96c54

Browse files
add checks for filename length
1 parent f3655ef commit 2b96c54

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bin/sanitycheck.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const DATA_KEYS = ['name', 'wildcard', 'storageFile', 'url', 'content', 'evaluat
171171
const SUPPORTS_DEVICES = ["BANGLEJS","BANGLEJS2"]; // device IDs allowed for 'supports'
172172
const METADATA_TYPES = ["app","clock","widget","bootloader","RAM","launch","scheduler","notify","locale","settings","textinput","module","clkinfo","defaultconfig"]; // values allowed for "type" field - listed in README.md
173173
const FORBIDDEN_FILE_NAME_CHARS = /[,;]/; // used as separators in appid.info
174+
const MAX_FILE_NAME_LENGTH = 28
174175
const VALID_DUPLICATES = [ '.tfmodel', '.tfnames' ];
175176
const GRANDFATHERED_ICONS = ["s7clk", "snek", "astral", "alpinenav", "slomoclock", "arrow", "pebble", "rebble"];
176177
const INTERNAL_FILES_IN_APP_TYPE = { // list of app types and files they SHOULD provide...
@@ -287,6 +288,7 @@ apps.forEach((app,appIdx) => {
287288
app.storage.forEach((file) => {
288289
if (!file.name) ERROR(`App ${app.id} has a file with no name`, {file:metadataFile});
289290
if (isGlob(file.name)) ERROR(`App ${app.id} storage file ${file.name} contains wildcards`, {file:metadataFile});
291+
if (file.name.length > MAX_FILE_NAME_LENGTH) ERROR(`App ${app.id} storage file name ${file.name} is longer than ${MAX_FILE_NAME_LENGTH} characters}`, {file:metadataFile})
290292
let char = file.name.match(FORBIDDEN_FILE_NAME_CHARS)
291293
if (char) ERROR(`App ${app.id} storage file ${file.name} contains invalid character "${char[0]}"`, {file:metadataFile})
292294
if (fileNames.includes(file.name) && !file.supports) // assume that there aren't duplicates if 'supports' is set
@@ -410,6 +412,8 @@ apps.forEach((app,appIdx) => {
410412
ERROR(`App ${app.id} data file ${data.name} has both name and wildcard`, {file:metadataFile});
411413
if (isGlob(data.name))
412414
ERROR(`App ${app.id} data file name ${data.name} contains wildcards`, {file:metadataFile});
415+
if (data.name && data.name.length > MAX_FILE_NAME_LENGTH)
416+
ERROR(`App ${app.id} data file name ${data.name} is longer than ${MAX_FILE_NAME_LENGTH} characters}`, {file:metadataFile})
413417
if (data.wildcard) {
414418
if (!isGlob(data.wildcard))
415419
ERROR(`App ${app.id} data file wildcard ${data.wildcard} does not actually contains wildcard`, {file:metadataFile});

0 commit comments

Comments
 (0)