This is an automated email from the ASF dual-hosted git repository. zzz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit d3ed0276545774d989d050fe57fdf7dd3877b49c Author: xinli1 <xin...@linkedin.com> AuthorDate: Wed Aug 14 22:17:44 2019 -0700 fix the bug if filter word included in param value --- proxy/logging/LogFilter.h | 69 +++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/proxy/logging/LogFilter.h b/proxy/logging/LogFilter.h index 1cb55fe..19a1f3d 100644 --- a/proxy/logging/LogFilter.h +++ b/proxy/logging/LogFilter.h @@ -401,37 +401,54 @@ wipeField(char **field, char *pattern, const char *uppercase_field) } const char *p1 = strstr(lookup_query_param, pattern); - int field_pos = p1 - lookup_query_param; - p1 = query_param + field_pos; - - if (p1) { - char tmp_text[strlen(buf_dest) + 10]; - char *temp_text = tmp_text; - memcpy(temp_text, buf_dest, (p1 - buf_dest)); - temp_text += (p1 - buf_dest); - const char *p2 = strstr(p1, "="); - if (p2) { - p2++; - memcpy(temp_text, p1, (p2 - p1)); - temp_text += (p2 - p1); - const char *p3 = strstr(p2, "&"); - if (p3) { - for (int i = 0; i < (p3 - p2); i++) { - temp_text[i] = 'X'; + if (!p1) { + return; + } else { + while(p1) { + //wipe pattern in param name, need search again if find pattern in param value + const char *p10 = strstr(p1, "="); + if (!p10) { + //no "=" after p1, means p1 is not in the param name, and no more param after it + return; + } + const char *p11 = strstr(p1, "&"); + if (p11 && p10 > p11) { + //"=" is after "&" followd by p1, means p1 is not in the param name + p1 = strstr(p11, pattern); + continue; + } + + int field_pos = p1 - lookup_query_param; + p1 = query_param + field_pos; + + char tmp_text[strlen(buf_dest) + 10]; + char *temp_text = tmp_text; + memcpy(temp_text, buf_dest, (p1 - buf_dest)); + temp_text += (p1 - buf_dest); + const char *p2 = strstr(p1, "="); + if (p2) { + p2++; + memcpy(temp_text, p1, (p2 - p1)); + temp_text += (p2 - p1); + const char *p3 = strstr(p2, "&"); + if (p3) { + for (int i = 0; i < (p3 - p2); i++) + temp_text[i] = 'X'; + temp_text += (p3 - p2); + memcpy(temp_text, p3, ((buf_dest + strlen(buf_dest)) - p3)); + } else { + for (int i = 0; i < ((buf_dest + strlen(buf_dest)) - p2); i++) { + temp_text[i] = 'X'; + } } - temp_text += (p3 - p2); - memcpy(temp_text, p3, ((buf_dest + strlen(buf_dest)) - p3)); } else { - for (int i = 0; i < ((buf_dest + strlen(buf_dest)) - p2); i++) { - temp_text[i] = 'X'; - } + return; } - } else { + + tmp_text[strlen(buf_dest)] = '\0'; + strcpy(*field, tmp_text); return; } - - tmp_text[strlen(buf_dest)] = '\0'; - strcpy(*field, tmp_text); } } }