"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/utils/test/js_unescape_test.cc" between
snort3-3.1.29.0.tar.gz and snort3-3.1.30.0.tar.gz

About: Snort 3 is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

js_unescape_test.cc  (snort3-3.1.29.0):js_unescape_test.cc  (snort3-3.1.30.0)
skipping to change at line 36 skipping to change at line 36
#include "utils/js_identifier_ctx.h" #include "utils/js_identifier_ctx.h"
#include "utils/js_normalizer.h" #include "utils/js_normalizer.h"
#include "js_test_utils.h" #include "js_test_utils.h"
#ifdef CATCH_TEST_BUILD #ifdef CATCH_TEST_BUILD
TEST_CASE("Sequence parsing", "[JSNormalizer]") TEST_CASE("Sequence parsing", "[JSNormalizer]")
{ {
SECTION("\\xXX") SECTION("\\xXX")
{
test_normalization(
"'\\x01'",
"'\u0001'"
);
test_normalization(
"'\\x23'",
"'\u0023'"
);
test_normalization(
"'\\x45'",
"'\u0045'"
);
test_normalization(
"'\\x67'",
"'\u0067'"
);
test_normalization(
"'\\x89'",
"'\u0089'"
);
test_normalization(
"'\\xaA'",
"'\u00aA'"
);
test_normalization(
"'\\xbB'",
"'\u00bB'"
);
test_normalization(
"'\\xcC'",
"'\u00cC'"
);
test_normalization(
"'\\xdD'",
"'\u00dD'"
);
test_normalization( test_normalization(
"'\\xeE'", "'\\x01 \\x23 \\x45 \\x67 \\x89 \\xaA \\xbB \\xcC \\xdD \\xeE \\xfF'
"'\u00eE'" ",
"'\u0001 \u0023 \u0045 \u0067 \u0089 \u00aA \u00bB \u00cC \u00dD \u0
0eE \u00fF'"
); );
SECTION("\\xXX - unescape function")
test_normalization( test_normalization(
"'\\xfF'", "unescape('\\x01 \\x23 \\x45 \\x67 \\x89 \\xaA \\xbB \\xcC \\xdD \\x
"'\u00fF'" eE \\xfF')",
"'\x01 \x23 \x45 \x67 \x89 \xaA \xbB \xcC \xdD \xeE \xfF'"
); );
}
SECTION("\\uXXXX") SECTION("\\uXXXX")
{
test_normalization(
"'\\u0123'",
"'\u0123'"
);
test_normalization(
"'\\u4567'",
"'\u4567'"
);
test_normalization(
"'\\u89aA'",
"'\u89aA'"
);
test_normalization( test_normalization(
"'\\ubBcC'", "'\\u0020 \\u00EB \\u0123 \\u4567 \\u89aA \\ubBcC \\u00dD \\ueEfF'",
"'\ubBcC'" "'\u0020 \u00EB \u0123 \u4567 \u89aA \ubBcC \u00dD \ueEfF'"
); );
test_normalization(
"'\\ueEfF'",
"'\ueEfF'"
);
}
SECTION("\\u{XXXX}") SECTION("\\u{XXXX}")
{
test_normalization(
"'\\u{0123}'",
"'\u0123'"
);
test_normalization(
"'\\u{4567}'",
"'\u4567'"
);
test_normalization(
"'\\u{89aA}'",
"'\u89aA'"
);
test_normalization(
"'\\u{bBcC}'",
"'\ubBcC'"
);
test_normalization( test_normalization(
"'\\u{eEfF}'", "'\\u{0020} \\u{00EB} \\u{0123} \\u{4567} \\u{89aA} \\u{bBcC} \\u{00
"'\ueEfF'" dD} \\u{eEfF}'",
"'\u0020 \u00EB \u0123 \u4567 \u89aA \ubBcC \u00dD \ueEfF'"
); );
}
SECTION("%XX") SECTION("%XX")
{
test_normalization(
"unescape('%01')",
"'\u0001'"
);
test_normalization(
"unescape('%23')",
"'\u0023'"
);
test_normalization(
"unescape('%45')",
"'\u0045'"
);
test_normalization(
"unescape('%67')",
"'\u0067'"
);
test_normalization(
"unescape('%89')",
"'\u0089'"
);
test_normalization(
"unescape('%aA')",
"'\u00aA'"
);
test_normalization(
"unescape('%bB')",
"'\u00bB'"
);
test_normalization( test_normalization(
"unescape('%cC')", "unescape('%01 %23 %45 %67 %89 %aA %bB %cC %dD %eE %fF')",
"'\u00cC'" "'\x01 \x23 \x45 \x67 \x89 \xaA \xbB \xcC \xdD \xeE \xfF'"
); );
test_normalization(
"unescape('%dD')",
"'\u00dD'"
);
test_normalization(
"unescape('%eE')",
"'\u00eE'"
);
test_normalization(
"unescape('%fF')",
"'\u00fF'"
);
}
SECTION("\\uXX") SECTION("\\uXX")
{
test_normalization(
"unescape('\\u01')",
"'\u0001'"
);
test_normalization(
"unescape('%23')",
"'\u0023'"
);
test_normalization(
"unescape('\\u45')",
"'\u0045'"
);
test_normalization(
"unescape('\\u67')",
"'\u0067'"
);
test_normalization(
"unescape('\\u89')",
"'\u0089'"
);
test_normalization( test_normalization(
"unescape('\\uaA')", "unescape('\\u01 \\u23 \\u45 \\u67 \\u89 \\uaA \\ubB \\ucC \\udD \\u
"'\u00aA'" eE \\ufF')",
"'\x01 \x23 \x45 \x67 \x89 \xaA \xbB \xcC \xdD \xeE \xfF'"
); );
test_normalization(
"unescape('\\ubB')",
"'\u00bB'"
);
test_normalization(
"unescape('\\ucC')",
"'\u00cC'"
);
test_normalization(
"unescape('\\udD')",
"'\u00dD'"
);
test_normalization(
"unescape('\\ueE')",
"'\u00eE'"
);
test_normalization(
"unescape('\\ufF')",
"'\u00fF'"
);
}
SECTION("%uXXXX") SECTION("%uXXXX")
{
test_normalization( test_normalization(
"unescape('%u0123')", "unescape('%u0020 %u00EB %u0123 %u4567 %u89aA %ubBcC %u00dD %ueEfF')
"'\u0123'" ",
"'\u0020 \u00EB \u0123 \u4567 \u89aA \ubBcC \u00dD \ueEfF'"
); );
test_normalization(
"unescape('%u4567')",
"'\u4567'"
);
test_normalization(
"unescape('%u89aA')",
"'\u89aA'"
);
test_normalization(
"unescape('%ubBcC')",
"'\ubBcC'"
);
test_normalization(
"unescape('%ueEfF')",
"'\ueEfF'"
);
}
SECTION("decimal") SECTION("decimal")
{ {
test_normalization( test_normalization(
"String.fromCharCode(1)", "String.fromCharCode(1, 12 ,235, 345, 6789, 1000, 0001)",
"'\u0001'" "'\u0001\u000c\u00EB\u0159\u1a85\u03e8\u0001'"
);
test_normalization(
"String.fromCharCode(12)",
"'\u000c'"
);
test_normalization(
"String.fromCharCode(345)",
"'\u0159'"
);
test_normalization(
"String.fromCharCode(6789)",
"'\u1a85'"
);
test_normalization(
"String.fromCharCode(1000)",
"'\u03e8'"
);
test_normalization(
"String.fromCharCode(0001)",
"'\x01'"
); );
test_normalization( test_normalization(
"String.fromCharCode(65536)", "String.fromCharCode(65536)",
"'\xf0\x90\x80\x80'" "'\xf0\x90\x80\x80'"
); );
test_normalization( test_normalization(
"String.fromCodePoint(2097152)", "String.fromCodePoint(2097152)",
"'\xf7\xbf\xbf\xbf'" "'\xf7\xbf\xbf\xbf'"
); );
} }
SECTION("hexadecimal") SECTION("hexadecimal")
{ {
test_normalization( test_normalization(
"String.fromCharCode(0x0001)", "String.fromCharCode(0x0001, 0X00EB, 0x0123, 0x4567, 0x89aA, 0xbBcC,
"'\u0001'" 0x00dD, 0xeEfF)",
); "'\u0001\u00EB\u0123\u4567\u89aA\ubBcC\u00dD\ueEfF'"
test_normalization(
"String.fromCharCode(0X0001)",
"'\u0001'"
);
test_normalization(
"String.fromCharCode(0x1234)",
"'\u1234'"
);
test_normalization(
"String.fromCharCode(0X5678)",
"'\u5678'"
);
test_normalization(
"String.fromCharCode(0x9aAb)",
"'\u9aAb'"
);
test_normalization(
"String.fromCharCode(0x9aAb)",
"'\u9aAb'"
);
test_normalization(
"String.fromCharCode(0xBcCd)",
"'\uBcCd'"
);
test_normalization(
"String.fromCharCode(0XeEfF)",
"'\ueEfF'"
); );
test_normalization( test_normalization(
"String.fromCodePoint(0x10000)", "String.fromCodePoint(0x10000)",
"'\xf0\x90\x80\x80'" "'\xf0\x90\x80\x80'"
); );
test_normalization( test_normalization(
"String.fromCharCode(0X10000)", "String.fromCharCode(0X10000)",
"'\xf0\x90\x80\x80'" "'\xf0\x90\x80\x80'"
); );
test_normalization( test_normalization(
skipping to change at line 345 skipping to change at line 123
"'\xf7\xbf\xbf\xbf'" "'\xf7\xbf\xbf\xbf'"
); );
} }
} }
TEST_CASE("Universal sequences", "[JSNormalizer]") TEST_CASE("Universal sequences", "[JSNormalizer]")
{ {
SECTION("\\uXXXX") SECTION("\\uXXXX")
{ {
test_normalization( test_normalization(
"\\u0065\\u0076\\u0061\\u006C () ;", "\\u0065\\u0076\\u0061\\u006C () ; \\u00EB\\u1234 ;",
"eval();" "eval();var_0000;"
); );
test_normalization( test_normalization(
"'\\u0062\\u0061\\u0072'", "'\\u0062\\u0061\\u0072' ; '\\u00EB\\ueEfF' ;",
"'bar'" "'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"\"\\u0062\\u0061\\u0072\"", "\"\\u0062\\u0061\\u0072\" ; \"\\u00EB\\ueEfF\" ;",
"\"bar\"" "\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"`\\u0062\\u0061\\u0072`", "`\\u0062\\u0061\\u0072` ; `\\u00EB\\ueEfF` ;",
"`bar`" "`bar`;`\u00EB\ueEfF`;"
); );
test_normalization( test_normalization(
"/\\u0062\\u0061\\u0072/", "/\\u0062\\u0061\\u0072/ ; /\\u00EB\\ueEfF/ ;",
"/bar/" "/bar/;/\u00EB\ueEfF/;"
); );
} }
SECTION("\\xXX") SECTION("\\xXX")
{ {
test_normalization( test_normalization(
"'\\x62\\x61\\x72'", "'\\x62\\x61\\x72' ; '\\xEB' ;",
"'bar'" "'bar';'\u00EB';"
); );
test_normalization( test_normalization(
"\"\\x62\\x61\\x72\"", "\"\\x62\\x61\\x72\" ; \"\\xEB\" ;",
"\"bar\"" "\"bar\";\"\u00EB\";"
); );
test_normalization( test_normalization(
"`\\x62\\x61\\x72`", "`\\x62\\x61\\x72` ; `\\xEB` ;",
"`bar`" "`bar`;`\u00EB`;"
); );
test_normalization( test_normalization(
"/\\x62\\x61\\x72/", "/\\x62\\x61\\x72/ ; /\\xEB/ ;",
"/bar/" "/bar/;/\u00EB/;"
); );
} }
SECTION("\\u{XXXX}") SECTION("\\u{XXXX}")
{ {
test_normalization( test_normalization(
"\\u{0065}\\u{0076}\\u{0061}\\u{006C} () ;", "\\u{0065}\\u{0076}\\u{0061}\\u{006C} () ; \\u{00EB}\\u{1234} ;",
"eval();" "eval();var_0000;"
); );
test_normalization( test_normalization(
"'\\u{0062}\\u{0061}\\u{0072}'", "'\\u{0062}\\u{0061}\\u{0072}'; '\\u{00EB}\\u{eEfF}' ;",
"'bar'" "'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"\"\\u{0062}\\u{0061}\\u{0072}\"", "\"\\u{0062}\\u{0061}\\u{0072}\" ; \"\\u{00EB}\\u{eEfF}\" ;",
"\"bar\"" "\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"`\\u{0062}\\u{0061}\\u{0072}`", "`\\u{0062}\\u{0061}\\u{0072}` ; `\\u{00EB}\\u{eEfF}` ;",
"`bar`" "`bar`;`\u00EB\ueEfF`;"
); );
} }
} }
TEST_CASE("unescape()", "[JSNormalizer]") TEST_CASE("unescape()", "[JSNormalizer]")
{ {
SECTION("%XX") SECTION("%XX")
{ {
test_normalization( test_normalization(
"unescape('%62%61%72')", "unescape('%62%61%72') ; unescape('%EB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"unescape(\"%62%61%72\")", "unescape(\"%62%61%72\") ; unescape(\"%EB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"unescape(`%62%61%72`)", "unescape(`%62%61%72`) ; unescape(`%EB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("%uXXXX") SECTION("%uXXXX")
{ {
test_normalization( test_normalization(
"unescape('%u0062%u0061%u0072')", "unescape('%u0062%u0061%u0072') ; unescape('%u00EB%ueEfF') ;",
"'bar'" "'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"unescape(\"%u0062%u0061%u0072\")", "unescape(\"%u0062%u0061%u0072\") ; unescape(\"%u00EB%ueEfF\") ;",
"\"bar\"" "\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"unescape(`%u0062%u0061%u0072`)", "unescape(`%u0062%u0061%u0072`) ; unescape(`%u00EB%ueEfF`) ;",
"`bar`" "`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("\\uXX") SECTION("\\uXX")
{ {
test_normalization( test_normalization(
"unescape('\\u62\\u61\\u72')", "unescape('\\u62\\u61\\u72') ; unescape('\\uEB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"unescape(\"\\u62\\u61\\u72\")", "unescape(\"\\u62\\u61\\u72\") ; unescape(\"\\uEB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"unescape(`\\u62\\u61\\u72`)", "unescape(`\\u62\\u61\\u72`) ; unescape(`\\uEB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("\\uXXXX") SECTION("\\uXXXX")
{ {
test_normalization( test_normalization(
"unescape('\\u0062\\u0061\\u0072')", "unescape('\\u0062\\u0061\\u0072') ; unescape('\\u00EB\\ueEfF') ;",
"'bar'" "'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"unescape(\"\\u0062\\u0061\\u0072\")", "unescape(\"\\u0062\\u0061\\u0072\") ; unescape(\"\\u00EB\\ueEfF\")
"\"bar\"" ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"unescape(`\\u0062\\u0061\\u0072`)", "unescape(`\\u0062\\u0061\\u0072`) ; unescape(`\\u00EB\\ueEfF`) ;",
"`bar`" "`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("\\xXX") SECTION("\\xXX")
{ {
test_normalization( test_normalization(
"unescape('\\x62\\x61\\x72')", "unescape('\\x62\\x61\\x72') ; unescape('\\xEB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"unescape(\"\\x62\\x61\\x72\")", "unescape(\"\\x62\\x61\\x72\") ; unescape(\"\\xEB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"unescape(`\\x62\\x61\\x72`)", "unescape(`\\x62\\x61\\x72`) ; unescape(`\\xEB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("\\u{XXXX}") SECTION("\\u{XXXX}")
{ {
test_normalization( test_normalization(
"unescape('\\u{0062}\\u{0061}\\u{0072}')", "unescape('\\u{0062}\\u{0061}\\u{0072}') ; unescape('\\u{00EB}\\u{eE
"'bar'" fF}') ;",
"'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"unescape(\"\\u{0062}\\u{0061}\\u{0072}\")", "unescape(\"\\u{0062}\\u{0061}\\u{0072}\") ; unescape(\"\\u{00EB}\\u
"\"bar\"" {eEfF}\") ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"unescape(`\\u{0062}\\u{0061}\\u{0072}`)", "unescape(`\\u{0062}\\u{0061}\\u{0072}`) ; unescape(`\\u{00EB}\\u{eE
"`bar`" fF}`) ;",
"`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("mixed sequence") SECTION("mixed sequence")
{ {
test_normalization_mixed_encoding( test_normalization_mixed_encoding(
"unescape('\\u62%61%72')", "unescape('\\u62%61%72')",
"'bar'" "'bar'"
); );
skipping to change at line 544 skipping to change at line 322
"'bar'" "'bar'"
); );
} }
} }
TEST_CASE("decodeURI()", "[JSNormalizer]") TEST_CASE("decodeURI()", "[JSNormalizer]")
{ {
SECTION("%XX") SECTION("%XX")
{ {
test_normalization( test_normalization(
"decodeURI('%62%61%72')", "decodeURI('%62%61%72') ; decodeURI('%EB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"decodeURI(\"%62%61%72\")", "decodeURI(\"%62%61%72\") ; decodeURI(\"%EB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"decodeURI(`%62%61%72`)", "decodeURI(`%62%61%72`) ; decodeURI(`%EB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("%uXXXX") SECTION("%uXXXX")
{ {
test_normalization( test_normalization(
"decodeURI('%u0062%u0061%u0072')", "decodeURI('%u0062%u0061%u0072') ; decodeURI('%u00EB%ueEfF') ;",
"'bar'" "'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"decodeURI(\"%u0062%u0061%u0072\")", "decodeURI(\"%u0062%u0061%u0072\") ; decodeURI(\"%u00EB%ueEfF\") ;",
"\"bar\"" "\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"decodeURI(`%u0062%u0061%u0072`)", "decodeURI(`%u0062%u0061%u0072`) ; decodeURI(`%u00EB%ueEfF`) ;",
"`bar`" "`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("\\uXX") SECTION("\\uXX")
{ {
test_normalization( test_normalization(
"decodeURI('\\u62\\u61\\u72')", "decodeURI('\\u62\\u61\\u72') ; decodeURI('\\uEB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"decodeURI(\"\\u62\\u61\\u72\")", "decodeURI(\"\\u62\\u61\\u72\") ; decodeURI(\"\\uEB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"decodeURI(`\\u62\\u61\\u72`)", "decodeURI(`\\u62\\u61\\u72`) ; decodeURI(`\\uEB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("\\uXXXX") SECTION("\\uXXXX")
{ {
test_normalization( test_normalization(
"decodeURI('\\u0062\\u0061\\u0072')", "decodeURI('\\u0062\\u0061\\u0072') ; decodeURI('\\u00EB\\ueEfF') ;"
"'bar'" ,
"'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"decodeURI(\"\\u0062\\u0061\\u0072\")", "decodeURI(\"\\u0062\\u0061\\u0072\") ; decodeURI(\"\\u00EB\\ueEfF\"
"\"bar\"" ) ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"decodeURI(`\\u0062\\u0061\\u0072`)", "decodeURI(`\\u0062\\u0061\\u0072`) ; decodeURI(`\\u00EB\\ueEfF`) ;"
"`bar`" ,
"`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("\\xXX") SECTION("\\xXX")
{ {
test_normalization( test_normalization(
"decodeURI('\\x62\\x61\\x72')", "decodeURI('\\x62\\x61\\x72') ; decodeURI('\\xEB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"decodeURI(\"\\x62\\x61\\x72\")", "decodeURI(\"\\x62\\x61\\x72\") ; decodeURI(\"\\xEB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"decodeURI(`\\x62\\x61\\x72`)", "decodeURI(`\\x62\\x61\\x72`) ; decodeURI(`\\xEB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("\\u{XXXX}") SECTION("\\u{XXXX}")
{ {
test_normalization( test_normalization(
"decodeURI('\\u{0062}\\u{0061}\\u{0072}')", "decodeURI('\\u{0062}\\u{0061}\\u{0072}') ; decodeURI('\\u{00EB}\\u{
"'bar'" eEfF}') ;",
"'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"decodeURI(\"\\u{0062}\\u{0061}\\u{0072}\")", "decodeURI(\"\\u{0062}\\u{0061}\\u{0072}\") ; decodeURI(\"\\u{00EB}\
"\"bar\"" \u{eEfF}\") ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"decodeURI(`\\u{0062}\\u{0061}\\u{0072}`)", "decodeURI(`\\u{0062}\\u{0061}\\u{0072}`) ; decodeURI(`\\u{00EB}\\u{
"`bar`" eEfF}`) ;",
"`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("mixed sequence") SECTION("mixed sequence")
{ {
test_normalization_mixed_encoding( test_normalization_mixed_encoding(
"decodeURI('\\u62%61%72')", "decodeURI('\\u62%61%72')",
"'bar'" "'bar'"
); );
skipping to change at line 676 skipping to change at line 454
"'bar'" "'bar'"
); );
} }
} }
TEST_CASE("decodeURIComponent()", "[JSNormalizer]") TEST_CASE("decodeURIComponent()", "[JSNormalizer]")
{ {
SECTION("%XX") SECTION("%XX")
{ {
test_normalization( test_normalization(
"decodeURIComponent('%62%61%72')", "decodeURIComponent('%62%61%72') ; decodeURIComponent('%EB') ;",
"'bar'" "'bar';'\xEB';"
); );
test_normalization( test_normalization(
"decodeURIComponent(\"%62%61%72\")", "decodeURIComponent(\"%62%61%72\") ; decodeURIComponent(\"%EB\") ;",
"\"bar\"" "\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"decodeURIComponent(`%62%61%72`)", "decodeURIComponent(`%62%61%72`) ; decodeURIComponent(`%EB`) ;",
"`bar`" "`bar`;`\xEB`;"
); );
} }
SECTION("%uXXXX") SECTION("%uXXXX")
{ {
test_normalization( test_normalization(
"decodeURIComponent('%u0062%u0061%u0072')", "decodeURIComponent('%u0062%u0061%u0072') ; decodeURIComponent('%u00
"'bar'" EB%ueEfF') ;",
"'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"decodeURIComponent(\"%u0062%u0061%u0072\")", "decodeURIComponent(\"%u0062%u0061%u0072\") ; decodeURIComponent(\"%
"\"bar\"" u00EB%ueEfF\") ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"decodeURIComponent(`%u0062%u0061%u0072`)", "decodeURIComponent(`%u0062%u0061%u0072`) ; decodeURIComponent(`%u00
"`bar`" EB%ueEfF`) ;",
"`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("\\uXX") SECTION("\\uXX")
{ {
test_normalization( test_normalization(
"decodeURIComponent('\\u62\\u61\\u72')", "decodeURIComponent('\\u62\\u61\\u72') ; decodeURIComponent('\\uEB')
"'bar'" ;",
"'bar';'\xEB';"
); );
test_normalization( test_normalization(
"decodeURIComponent(\"\\u62\\u61\\u72\")", "decodeURIComponent(\"\\u62\\u61\\u72\") ; decodeURIComponent(\"\\uE
"\"bar\"" B\") ;",
"\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"decodeURIComponent(`\\u62\\u61\\u72`)", "decodeURIComponent(`\\u62\\u61\\u72`) ; decodeURIComponent(`\\uEB`)
"`bar`" ;",
"`bar`;`\xEB`;"
); );
} }
SECTION("\\uXXXX") SECTION("\\uXXXX")
{ {
test_normalization( test_normalization(
"decodeURIComponent('\\u0062\\u0061\\u0072')", "decodeURIComponent('\\u0062\\u0061\\u0072') ; decodeURIComponent('\
"'bar'" \u00EB\\ueEfF') ;",
"'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"decodeURIComponent(\"\\u0062\\u0061\\u0072\")", "decodeURIComponent(\"\\u0062\\u0061\\u0072\") ; "
"\"bar\"" "decodeURIComponent(\"\\u00EB\\ueEfF\") ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"decodeURIComponent(`\\u0062\\u0061\\u0072`)", "decodeURIComponent(`\\u0062\\u0061\\u0072`) ; decodeURIComponent(`\
"`bar`" \u00EB\\ueEfF`) ;",
"`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("\\xXX") SECTION("\\xXX")
{ {
test_normalization( test_normalization(
"decodeURIComponent('\\x62\\x61\\x72')", "decodeURIComponent('\\x62\\x61\\x72') ; decodeURIComponent('\\xEB')
"'bar'" ;",
"'bar';'\xEB';"
); );
test_normalization( test_normalization(
"decodeURIComponent(\"\\x62\\x61\\x72\")", "decodeURIComponent(\"\\x62\\x61\\x72\") ; decodeURIComponent(\"\\xE
"\"bar\"" B\") ;",
"\"bar\";\"\xEB\";"
); );
test_normalization( test_normalization(
"decodeURIComponent(`\\x62\\x61\\x72`)", "decodeURIComponent(`\\x62\\x61\\x72`) ; decodeURIComponent(`\\xEB`)
"`bar`" ;",
"`bar`;`\xEB`;"
); );
} }
SECTION("\\u{XXXX}") SECTION("\\u{XXXX}")
{ {
test_normalization( test_normalization(
"decodeURIComponent('\\u{0062}\\u{0061}\\u{0072}')", "decodeURIComponent('\\u{0062}\\u{0061}\\u{0072}') ; "
"'bar'" "decodeURIComponent('\\u{00EB}\\u{eEfF}') ;",
"'bar';'\u00EB\ueEfF';"
); );
test_normalization( test_normalization(
"decodeURIComponent(\"\\u{0062}\\u{0061}\\u{0072}\")", "decodeURIComponent(\"\\u{0062}\\u{0061}\\u{0072}\") ; "
"\"bar\"" "decodeURIComponent(\"\\u{00EB}\\u{eEfF}\") ;",
"\"bar\";\"\u00EB\ueEfF\";"
); );
test_normalization( test_normalization(
"decodeURIComponent(`\\u{0062}\\u{0061}\\u{0072}`)", "decodeURIComponent(`\\u{0062}\\u{0061}\\u{0072}`) ; "
"`bar`" "decodeURIComponent(`\\u{00EB}\\u{eEfF}`) ;",
"`bar`;`\u00EB\ueEfF`;"
); );
} }
SECTION("mixed sequence") SECTION("mixed sequence")
{ {
test_normalization_mixed_encoding( test_normalization_mixed_encoding(
"decodeURIComponent('\\u62%61%72')", "decodeURIComponent('\\u62%61%72')",
"'bar'" "'bar'"
); );
skipping to change at line 1291 skipping to change at line 1073
"String.fromCodePoint(0x0062, 0x0061, String.fromCharCode(0x0062, 0x 0061, 0x0072));", "String.fromCodePoint(0x0062, 0x0061, String.fromCharCode(0x0062, 0x 0061, 0x0072));",
"'ba' 'bar';" "'ba' 'bar';"
); );
test_normalization( test_normalization(
"String.fromCharCode(0x0062, 0x0061, String.fromCodePoint(0x0062, 0x 0061, 0x0072));", "String.fromCharCode(0x0062, 0x0061, String.fromCodePoint(0x0062, 0x 0061, 0x0072));",
"'ba' 'bar';" "'ba' 'bar';"
); );
} }
} }
TEST_CASE("Internal limits", "[JSNormalizer]")
{
SECTION("output tail size")
{
test_normalization(
"function v(e){return new String(/^(?:(?:(?:https?|ftp):)?\\/\\/)(?"
":\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.2"
"54|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:"
"\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?"
"\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\"
"d|25[0-4]))|(?:(?:[a-z 0-9\\u0061-\\u007a][a-z 0-9\\u0061-\\u007a_"
"-]{0,62})?[a-z 0-9\\u0061-\\u007a]\\.)+(?:[a-z \\u0061-\\u007a]{2,"
"}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$/i).test(e)}",
"function var_0000(var_0001){return new String(/^(?:(?:(?:https?|ft"
"p):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3}"
")(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2"
"\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3"
"])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\"
"d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z 0-9a-z][a-z 0-9a-z_-]{0,62})?["
"a-z 0-9a-z]\\.)+(?:[a-z a-z]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?"
"$/i).test(var_0001)}"
);
}
}
#endif // CATCH_TEST_BUILD #endif // CATCH_TEST_BUILD
 End of changes. 90 change blocks. 
376 lines changed or deleted 211 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)