Regex string threaded literally instead as regex

During shellcheck of Hestia source code I noticed the following error matching the line:
^----^ SC2076: Don't quote right-hand side of =~, it'll match literally rather than as a regex.
                                                                                      ^--------------^ SC2076: Don't quote right-hand side of =~, it'll match literally rather 
Proof of concept:
root@dev:~# v-add-web-domain jaap jaap..nu 
Error: nginx restart failed
root@dev:~# v-add-web-domain jaap jaap..nu 
Error: invalid domain format :: jaap..nu
This commit is contained in:
Jaap Marcus 2021-10-18 09:31:48 +02:00 committed by GitHub
parent 8bbfc1255f
commit a493c140ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -551,7 +551,7 @@ is_user_format_valid() {
is_domain_format_valid() { is_domain_format_valid() {
object_name=${2-domain} object_name=${2-domain}
exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]" exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
if [[ $1 =~ $exclude ]] || [[ $1 =~ ^[0-9]+$ ]] || [[ $1 =~ "\.\." ]] || [[ $1 =~ "$(printf '\t')" ]]; then if [[ $1 =~ $exclude ]] || [[ $1 =~ ^[0-9]+$ ]] || [[ $1 =~ \.\. ]] || [[ $1 =~ $(printf '\t') ]]; then
check_result $E_INVALID "invalid $object_name format :: $1" check_result $E_INVALID "invalid $object_name format :: $1"
fi fi
} }