INF_JS_OPENING_TAG,
INF_JS_CLOSING_TAG,
INF_JS_CODE_IN_EXTERNAL,
+ INF_JS_SHORTENED_TAG,
INF__MAX_VALUE
};
EVENT_JS_OPENING_TAG = 266,
EVENT_JS_CLOSING_TAG = 267,
EVENT_JS_CODE_IN_EXTERNAL = 268,
+ EVENT_JS_SHORTENED_TAG = 269,
EVENT__MAX_VALUE
};
mpse_type = new SearchTool;
static constexpr const char* otag_start = "<SCRIPT";
+ static constexpr const char* attr_slash = "/";
static constexpr const char* attr_gt = ">";
static constexpr const char* attr_src = "SRC";
static constexpr const char* attr_js1 = "JAVASCRIPT";
static constexpr const char* attr_vb = "VBSCRIPT";
mpse_otag->add(otag_start, strlen(otag_start), 0);
+ mpse_attr->add(attr_slash, strlen(attr_slash), AID_SLASH);
mpse_attr->add(attr_gt, strlen(attr_gt), AID_GT);
mpse_attr->add(attr_src, strlen(attr_src), AID_SRC);
mpse_attr->add(attr_js1, strlen(attr_js1), AID_JS);
if (ptr >= end)
break;
- MatchContext sctx = {ptr, true, false};
+ MatchContext sctx = {ptr, true, false, false};
if (ptr[0] == '>')
ptr++;
ptr = sctx.next;
}
+ if (sctx.is_shortened)
+ {
+ *infractions += INF_JS_SHORTENED_TAG;
+ events->create_event(EVENT_JS_SHORTENED_TAG);
+ continue;
+ }
+
if (!sctx.is_javascript)
continue;
switch (id)
{
+ case AID_SLASH:
+ if (*(ctx->next + index) == '>')
+ {
+ ctx->is_shortened = true;
+ ctx->next += index;
+ return 1;
+ }
+ else
+ {
+ ctx->is_shortened = false;
+ return 0;
+ }
+
case AID_GT:
ctx->next += index;
return 1;
return 0;
default:
- ctx->next += index;
ctx->is_external = false;
ctx->is_javascript = false;
+ ctx->next += index;
return 1;
}
}
void configure();
private:
- enum AttrId { AID_GT, AID_SRC, AID_JS, AID_ECMA, AID_VB };
+ enum AttrId { AID_SLASH, AID_GT, AID_SRC, AID_JS, AID_ECMA, AID_VB };
struct MatchContext
{
const char* next;
bool is_javascript;
bool is_external;
+ bool is_shortened;
};
const HttpParaList::UriParam& uri_param;
{ EVENT_JS_OPENING_TAG, "unexpected script opening tag in JavaScript" },
{ EVENT_JS_CLOSING_TAG, "unexpected script closing tag in JavaScript" },
{ EVENT_JS_CODE_IN_EXTERNAL, "JavaScript code under the external script tags" },
+ { EVENT_JS_SHORTENED_TAG, "script opening tag in a short form" },
{ 0, nullptr }
};