diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index 34723b1..80721b2 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -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; diff --git a/plugin/business/pangu-http/src/pattern_replace.cpp b/plugin/business/pangu-http/src/pattern_replace.cpp index 086970c..34bb084 100644 --- a/plugin/business/pangu-http/src/pattern_replace.cpp +++ b/plugin/business/pangu-http/src/pattern_replace.cpp @@ -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, ""); 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, ""); - if (script_local && strstr(script_local, "")) - insert_from = script_local + sizeof(""); + script_local=strstr(insert_from, ""); + if (script_local) + insert_from=script_local + sizeof(""); } else { - insert_from=strstr(in, ""); + insert_from=head_in; } return insert_from; }