1.修复bug268js注入无效

This commit is contained in:
fengweihao
2019-06-17 21:28:48 +08:00
parent d197723309
commit 43f4788c33
2 changed files with 8 additions and 6 deletions

View File

@@ -1411,7 +1411,7 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
rewrite_buff = NULL;
rewrite_sz = 0;
if (in_resp_spec != NULL && in_resp_spec->content_type != NULL
if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL
&& strstr(in_resp_spec->content_type, "charset=utf-8"))
{
options = 1;

View File

@@ -288,22 +288,24 @@ static char *find_insert_position(char * in)
{
char *insert_from = NULL;
char *script_local = NULL;
char *head_in = NULL;
if (in == NULL)
{
return NULL;
}
head_in = strstr(in, "</head>");
insert_from = strstr(in, "jquery");
if (insert_from != NULL)
if (insert_from != NULL && head_in != NULL && (head_in - insert_from) > 0)
{
script_local = strstr(insert_from, "</script>");
if (script_local && strstr(script_local, "</head>"))
insert_from = script_local + sizeof("</script>");
script_local=strstr(insert_from, "</script>");
if (script_local)
insert_from=script_local + sizeof("</script>");
}
else
{
insert_from=strstr(in, "</head>");
insert_from=head_in;
}
return insert_from;
}