This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 7c15990e6844478e071248addc98f68c21cff796 Author: Leif Hedstrom <[email protected]> AuthorDate: Thu Jul 18 21:40:49 2024 -0600 Removes matrix parameters from regex_remap plugin (#11571) (cherry picked from commit 3289fb0b73af1b84aaf434b67123bd1fe7fb0d10) --- doc/admin-guide/plugins/regex_remap.en.rst | 6 --- plugins/regex_remap/regex_remap.cc | 62 +++++++++--------------------- 2 files changed, 19 insertions(+), 49 deletions(-) diff --git a/doc/admin-guide/plugins/regex_remap.en.rst b/doc/admin-guide/plugins/regex_remap.en.rst index d5744ebe33..547309faca 100644 --- a/doc/admin-guide/plugins/regex_remap.en.rst +++ b/doc/admin-guide/plugins/regex_remap.en.rst @@ -70,7 +70,6 @@ be used to modify the plugin instance behavior :: @pparam=[no-]method [default: off] @pparam=[no-]query-string [default: on] - @pparam=[no-]matrix-parameters [default: off] @pparam=[no-]host [default: off] If you wish to match on the HTTP method used (e.g. "``GET``\ "), @@ -92,11 +91,6 @@ again, to turn this off use the option 'no-query-string', e.g. :: ... @pparam=maps.reg @pparam=no-query-string -You can also include the matrix parameters in the string, using -the option 'matrix-parameters', e.g. :: - - ... @pparam=maps.reg @pparam=matrix-parameters - Finally, to match on the host as well, use the option 'host', e.g. :: ... @pparam=maps.reg @pparam=host diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc index 350557bc2d..ca838c23ef 100644 --- a/plugins/regex_remap/regex_remap.cc +++ b/plugins/regex_remap/regex_remap.cc @@ -59,14 +59,14 @@ static const int MAX_SUBS = 32; // No more than 32 substitution variables in th // Substitutions other than regex matches enum ExtraSubstitutions { - SUB_HOST = 11, - SUB_FROM_HOST = 12, - SUB_TO_HOST = 13, - SUB_PORT = 14, - SUB_SCHEME = 15, - SUB_PATH = 16, - SUB_QUERY = 17, - SUB_MATRIX = 18, + SUB_HOST = 11, + SUB_FROM_HOST = 12, + SUB_TO_HOST = 13, + SUB_PORT = 14, + SUB_SCHEME = 15, + SUB_PATH = 16, + SUB_QUERY = 17, + // 18 is unused, used to be matrix parameters SUB_CLIENT_IP = 19, SUB_LOWER_PATH = 20, }; @@ -87,24 +87,21 @@ struct UrlComponents { host = TSUrlHostGet(bufp, url, &host_len); path = TSUrlPathGet(bufp, url, &path_len); query = TSUrlHttpQueryGet(bufp, url, &query_len); - matrix = TSUrlHttpParamsGet(bufp, url, &matrix_len); port = TSUrlPortGet(bufp, url); - url_len = scheme_len + host_len + path_len + query_len + matrix_len + 32; + url_len = scheme_len + host_len + path_len + query_len + 32; } const char *scheme = nullptr; const char *host = nullptr; const char *path = nullptr; const char *query = nullptr; - const char *matrix = nullptr; int port = 0; int scheme_len = 0; int host_len = 0; int path_len = 0; int query_len = 0; - int matrix_len = 0; int url_len = 0; // Full length, of all components }; @@ -442,9 +439,6 @@ RemapRegex::compile(const char *&error, int &erroffset) case 'q': ix = SUB_QUERY; break; - case 'm': - ix = SUB_MATRIX; - break; case 'i': ix = SUB_CLIENT_IP; break; @@ -515,9 +509,6 @@ RemapRegex::get_lengths(const int ovector[], int lengths[], TSRemapRequestInfo * case SUB_QUERY: len += req_url->query_len; break; - case SUB_MATRIX: - len += req_url->matrix_len; - break; case SUB_CLIENT_IP: len += INET6_ADDRSTRLEN; break; @@ -583,10 +574,6 @@ RemapRegex::substitute(char dest[], const char *src, const int ovector[], const str = req_url->query; len = req_url->query_len; break; - case SUB_MATRIX: - str = req_url->matrix; - len = req_url->matrix_len; - break; case SUB_CLIENT_IP: str = ats_ip_ntop(TSHttpTxnClientAddrGet(txnp), buff, INET6_ADDRSTRLEN); len = strlen(str); @@ -627,17 +614,16 @@ RemapRegex::substitute(char dest[], const char *src, const int ovector[], const struct RemapInstance { RemapInstance() : filename("unknown") {} - RemapRegex *first = nullptr; - RemapRegex *last = nullptr; - bool pristine_url = false; - bool profile = false; - bool method = false; - bool query_string = true; - bool matrix_params = false; - bool host = false; - int hits = 0; - int misses = 0; - int failures = 0; + RemapRegex *first = nullptr; + RemapRegex *last = nullptr; + bool pristine_url = false; + bool profile = false; + bool method = false; + bool query_string = true; + bool host = false; + int hits = 0; + int misses = 0; + int failures = 0; std::string filename; }; @@ -689,10 +675,6 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE ri->query_string = true; } else if (strncmp(argv[i], "no-query-string", 15) == 0) { ri->query_string = false; - } else if (strncmp(argv[i], "matrix-parameters", 17) == 0) { - ri->matrix_params = true; - } else if (strncmp(argv[i], "no-matrix-parameters", 20) == 0) { - ri->matrix_params = false; } else if (strncmp(argv[i], "host", 4) == 0) { ri->host = true; } else if (strncmp(argv[i], "no-host", 7) == 0) { @@ -957,12 +939,6 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri) match_len += (req_url.path_len); } - if (ri->matrix_params && req_url.matrix && req_url.matrix_len > 0) { - *(match_buf + match_len) = ';'; - memcpy(match_buf + match_len + 1, req_url.matrix, req_url.matrix_len); - match_len += (req_url.matrix_len + 1); - } - if (ri->query_string && req_url.query && req_url.query_len > 0) { *(match_buf + match_len) = '?'; memcpy(match_buf + match_len + 1, req_url.query, req_url.query_len);
