1.修复由于页面中存在jquery库的异步处理,造成页面加载css,jss失败
This commit is contained in:
@@ -1740,8 +1740,11 @@ static void http_insert(const struct tfe_stream * stream, const struct tfe_http_
|
||||
rewrite_buff = NULL;
|
||||
rewrite_sz = 0;
|
||||
|
||||
rewrite_sz = execute_insert_rule(http_body, http_body_len, ins_ctx->rule, &rewrite_buff);
|
||||
if (rewrite_sz >0 && strstr(cont_type_val, "text/html"))
|
||||
if (strstr(cont_type_val, "text/html") != NULL)
|
||||
{
|
||||
rewrite_sz = execute_insert_rule(http_body, http_body_len, ins_ctx->rule, &rewrite_buff);
|
||||
}
|
||||
if (rewrite_sz >0)
|
||||
{
|
||||
tfe_http_half_append_body(ins_ctx->replacing, rewrite_buff, rewrite_sz, 0);
|
||||
ins_ctx->actually_replaced=1;
|
||||
|
||||
@@ -283,6 +283,25 @@ size_t execute_replace_rule(const char * in, size_t in_sz,
|
||||
}
|
||||
}
|
||||
|
||||
static char *find_insert_position(char * in)
|
||||
{
|
||||
char *insert_from = NULL;
|
||||
char *script_local = NULL;
|
||||
|
||||
insert_from = strstr(in, "jquery");
|
||||
if (insert_from != NULL)
|
||||
{
|
||||
script_local = strstr(insert_from, "</script>");
|
||||
if (script_local && strstr(script_local, "</head>"))
|
||||
insert_from = script_local + sizeof("</script>");
|
||||
}
|
||||
else
|
||||
{
|
||||
insert_from=strstr(in, "</head>");
|
||||
}
|
||||
return insert_from;
|
||||
}
|
||||
|
||||
size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char *script, const char *type, char** out)
|
||||
{
|
||||
char *target=NULL;
|
||||
@@ -302,7 +321,7 @@ size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char
|
||||
}
|
||||
else
|
||||
{
|
||||
insert_from=strstr(in, "</head>");
|
||||
insert_from=find_insert_position(in);
|
||||
}
|
||||
if(!insert_from)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user