return FuncType::GENERAL;
case IDENTIFIER:
- {
- FuncType ret = FuncType::GENERAL;
-
- if (meta_type() == ScopeMetaType::FUNCTION)
- return ret;
+ if (meta_type() == ScopeMetaType::FUNCTION or ignored_id_pos < 0)
+ return FuncType::GENERAL;
- if (ignored_id_pos >= 0)
{
+ char tail[256];
std::streambuf* pbuf = yyout.rdbuf();
std::streamsize size = pbuf->pubseekoff(0, yyout.cur, yyout.out) - ignored_id_pos;
- assert(size >= 0);
- char tail[256];
- assert((size_t)size <= sizeof(tail));
- size = std::min((size_t)size, sizeof(tail));
+ if (size <= 0)
+ return FuncType::GENERAL;
+ size = std::min((size_t)size, sizeof(tail));
pbuf->pubseekoff(-size, yyout.cur, yyout.out);
pbuf->sgetn(tail, size);
if ((unsigned)size == (unsigned)id.identifier.size() &&
memcmp(tail, id.identifier.data(), size) == 0)
{
- ret = id.type;
pbuf->pubseekoff(-size, yyout.cur, yyout.out);
-
- break;
+ return id.type;
}
}
+
+ return FuncType::GENERAL;
}
- return ret;
- }
default:
return FuncType::NOT_FUNC;
}
}
+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