mirror of
https://github.com/nortakales/flipper-zero-tonies.git
synced 2025-12-06 06:45:05 +01:00
Add filename validation, rename some files
This commit is contained in:
parent
13eb1e1a39
commit
6bec1893e6
9 changed files with 9 additions and 0 deletions
|
|
@ -29,10 +29,19 @@ FORBIDDEN_PATTERNS=(
|
||||||
"Subtype: ([0-9]){2}"
|
"Subtype: ([0-9]){2}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FILE_AND_DIR_ALLOWED_CHARACTERS="A-Za-z0-9().,!%&+ -";
|
||||||
|
FILE_AND_DIR_REGEX="^\.[$FILE_AND_DIR_ALLOWED_CHARACTERS/]+\/[$FILE_AND_DIR_ALLOWED_CHARACTERS]+\.nfc$"
|
||||||
|
|
||||||
# Use process substitution so that ERROR_FOUND is updated in the main shell.
|
# Use process substitution so that ERROR_FOUND is updated in the main shell.
|
||||||
while read -r filename; do
|
while read -r filename; do
|
||||||
content=$(cat "$filename")
|
content=$(cat "$filename")
|
||||||
|
|
||||||
|
if ! echo "$filename" | awk "/$FILE_AND_DIR_REGEX/ { found=1 } END { exit !found }"; then
|
||||||
|
echo "$filename"
|
||||||
|
echo " Filename has invalid characters or missing .nfc extension. Allowed characters are $FILE_AND_DIR_ALLOWED_CHARACTERS"
|
||||||
|
ERROR_FOUND=1
|
||||||
|
fi
|
||||||
|
|
||||||
for pattern in "${REQUIRED_PATTERNS[@]}"; do
|
for pattern in "${REQUIRED_PATTERNS[@]}"; do
|
||||||
if ! echo "$content" | awk "/$pattern/ { found=1 } END { exit !found }"; then
|
if ! echo "$content" | awk "/$pattern/ { found=1 } END { exit !found }"; then
|
||||||
echo "$filename"
|
echo "$filename"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue