Fix escaping on Jim critical characters - {}[];

This commit is contained in:
prpr 2024-01-25 22:43:11 +00:00
parent f85e83f1df
commit 230491ca76

View File

@ -101,9 +101,13 @@ proc ::js::_unescape {str} {
}
proc ::js::escape {str} {
return [subst -nobackslashes -novariables \
[regsub -all -- {[^A-Za-z0-9@*_+./-]+} $str \
{[::js::_escape {&}]}]]
set re1 {[\;\[\]\{\}]}
set re2 {[^A-Za-z0-9@*_+./-]+}
regsub -all -- $re1 $str {\\&} str1
regsub -all -- $re2 $str1 \
{[subst -nobackslashes -novariables \
[::js::_escape [subst {&}]]]} str2
return [subst -nobackslashes -novariables $str2]
}
proc ::js::unescape {str} {