From 048c60439d26c761694f1519592da0593d3fb261 Mon Sep 17 00:00:00 2001 From: fengweihao Date: Sat, 15 Jun 2019 18:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=84=E5=88=99=E5=91=BD?= =?UTF-8?q?=E4=B8=AD=E5=BA=94=E7=AD=94=E5=A4=B4=E5=90=8E=EF=BC=8Credirect?= =?UTF-8?q?=E3=80=81block=E6=97=A0=E6=95=88=20=E4=BF=AE=E5=A4=8D=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E5=8A=A0=E8=BD=BDinset=E6=96=87=E4=BB=B6=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=EF=BC=8C=E5=90=8E=E7=BB=AD=E5=A4=84=E7=90=86=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/pangu-http/src/pangu_http.cpp | 10 +++++++--- plugin/business/pangu-http/src/pattern_replace.cpp | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index 0dc6809..3f318c1 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -1006,7 +1006,8 @@ void http_repl_ctx_free(struct replace_ctx* rep_ctx) void http_ins_ctx_free(struct insert_ctx* ins_ctx) { - FREE(&ins_ctx->rule->script); + if (ins_ctx->rule->script) + FREE(&ins_ctx->rule->script); FREE(&ins_ctx->rule->type); if (ins_ctx->rule->position) FREE(&ins_ctx->rule->position); @@ -1404,7 +1405,8 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio rewrite_buff = NULL; rewrite_sz = 0; - if (in_resp_spec->content_type != NULL && strstr(in_resp_spec->content_type, "charset=utf-8")) + if (in_resp_spec != NULL && in_resp_spec->content_type != NULL + && strstr(in_resp_spec->content_type, "charset=utf-8")) { options = 1; } @@ -1831,6 +1833,7 @@ enum pangu_action http_scan(const struct tfe_http_session * session, enum tfe_ht void * iterator = NULL; const char * field_val = NULL; struct http_field_name field_name; + struct tfe_http_half * http_half; struct Maat_rule_t result[MAX_SCAN_RESULT]; char buff[TFE_STRING_MAX], * p = NULL; int scan_ret = 0, table_id = 0; @@ -1854,9 +1857,10 @@ enum pangu_action http_scan(const struct tfe_http_session * session, enum tfe_ht { table_id = events & EV_HTTP_REQ_HDR ? g_pangu_rt->scan_table_id[PXY_CTRL_HTTP_REQ_HDR] : g_pangu_rt ->scan_table_id[PXY_CTRL_HTTP_RES_HDR]; + http_half = events & EV_HTTP_REQ_HDR ? session->req : session->resp; while (hit_cnt < MAX_SCAN_RESULT) { - field_val = tfe_http_field_iterate(session->req, &iterator, &field_name); + field_val = tfe_http_field_iterate(http_half, &iterator, &field_name); if (field_val == NULL) { break; diff --git a/plugin/business/pangu-http/src/pattern_replace.cpp b/plugin/business/pangu-http/src/pattern_replace.cpp index c5a5f4b..086970c 100644 --- a/plugin/business/pangu-http/src/pattern_replace.cpp +++ b/plugin/business/pangu-http/src/pattern_replace.cpp @@ -321,6 +321,11 @@ size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char char* insert_from=NULL; size_t offset=0; + if (script == NULL) + { + return 0; + } + if (insert_on != NULL && 0==strcasecmp(insert_on, "after-page-load")) { insert_from=strstr(in, "");