To get something you can inlineuse Data::JavaScript; print 'alert("', Data::JavaScript::__quotemeta(qq,ab\x22q\x27uo\x27te\x22cd,), '");',"\n"; __END__ alert("ab\"q'uo'te\"cd");
which you can use likeperl -MData::JavaScript -MData::Dumper -e ' $Data::Dumper::Deparse=1; +die Dumper \&Data::JavaScript::__quotemeta '
$VAR1 = sub { package Data::JavaScript; use strict 'refs'; local $_ = shift @_; if ($OPT{'JS'} >= 1.3 and &Encode::is_utf8($_)) { s/([\x{0080}-\x{fffd}]+)/sprintf '\\u%0*v4X', '\\u', $ +1;/eg; } { use bytes; s/((?:[^ \x21-\x7E]|(?:\\(?!u)))+)/sprintf '\\x%0*v2X' +, '\\x', $1;/eg; } s/\\x09/\\t/g; s/\\x0A/\\n/g; s/\\x0D/\\r/g; s/"/\\"/g; s/\\x5C/\\\\/g; s[</script>][\\x3C\\x2Fscript\\x3E]g; return $_; }; print 'alert("', $VAR1->(qq,ab\x22q\x27uo\x27te\x22cd,), '");',"\n"; __END__ alert("ab\"q'uo'te\"cd");
In reply to Re^2: Quote Escape
by Anonymous Monk
in thread Quote Escape
by pileofrogs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |