diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/idl2wrs.sh.in | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/idl2wrs.sh.in b/tools/idl2wrs.sh.in index 9fa33ba0be..ec3a4cfa4c 100644 --- a/tools/idl2wrs.sh.in +++ b/tools/idl2wrs.sh.in @@ -48,6 +48,25 @@ if [ $# -lt 1 ]; then exit 1; fi +# Check the file name for valid characters. +# Implementation based on Dave Taylor's validalnum shell script from his book, +# "Wicked Cool Shell Scripts", as well as Mark Rushakoff's answer he provided +# to the question posted at stackoverflow.com entitled, "How can I use the +# UNIX shell to count the number of times a letter appears in a text file?" +file=$(basename $1) +compressed="$(echo $file | sed 's/[^[:alnum:]._]//g')" +if [ "$compressed" != "$file" ]; then + echo "idl2wrs Error: Invalid file name: $file" + exit 1; +fi + +# Only allow one '.' at most. +count=$(echo $compressed | awk -F. '{c += NF - 1} END {print c}') +if [ $count -gt 1 ] ; then + echo "idl2wrs Error: Invalid file name: $file" + exit 1; +fi + # # Run wireshark backend, looking for wireshark_be.py and wireshark_gen.py # in pythons's "site-packages" directory. If cannot find that, then |