- Check for invalid characters before further processing. Allow only
alphanumeric characters, "-", "+" and ".".
- Convert "." to "\." before using user input in a sed expression.
- Reject zero-length extension names.
- Quote variables used in echo commands, to avoid unwanted shell
expansions.
Without these changes, various invalid inputs would be accepted, for
example due to misparsing of "*" and "." characters in regexps and
shell expansions. Some inputs could also lead to an infinite loop.