You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/10/07 15:59:08 UTC

[trafficserver] branch 9.2.x updated: Fix regex_remap plugin redirection. (#8359)

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 59287b9  Fix regex_remap plugin redirection. (#8359)
59287b9 is described below

commit 59287b92878545cb8163f1ed5c445548402d38d7
Author: Walt Karas <wk...@verizonmedia.com>
AuthorDate: Tue Oct 5 17:49:30 2021 -0500

    Fix regex_remap plugin redirection. (#8359)
    
    (cherry picked from commit c2d35047faf21b917e1cf9e6418280fcbb507eca)
---
 plugins/regex_remap/regex_remap.cc                                     | 3 +--
 tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold | 2 +-
 tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py            | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 5d16867..aa48812 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -1067,8 +1067,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
           const char *start = dest;
 
           // Setup the new URL
-          if (TS_PARSE_ERROR == TSUrlParse(rri->redirect ? src_url.bufp : rri->requestBufp,
-                                           rri->redirect ? src_url.loc : rri->requestUrl, &start, start + dest_len)) {
+          if (TS_PARSE_ERROR == TSUrlParse(rri->requestBufp, rri->requestUrl, &start, start + dest_len)) {
             TSHttpTxnStatusSet(txnp, TS_HTTP_STATUS_INTERNAL_SERVER_ERROR);
             TSError("[%s] can't parse substituted URL string", PLUGIN_NAME);
           }
diff --git a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold
index de8c55e..a05933e 100644
--- a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold
+++ b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold
@@ -1,2 +1,2 @@
 HTTP/1.1 301 Redirect
-Location: http://localhost:SERVER_PORT/alpha/bravo/?action=newsfed;param0001=00003E;param0002=00004E;param0003=00005E
+Location: https://redirect.com/
diff --git a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
index eee6459..f251392 100644
--- a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
+++ b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
@@ -58,7 +58,7 @@ curl_and_args = 'curl -s -D - -v --proxy localhost:{} '.format(ts.Variables.port
 
 ts.Disk.File(regex_remap_conf_path, typename="ats:config").AddLines([
     "# regex_remap configuration\n"
-    "^/alpha/bravo/[?]((?!action=(newsfeed|calendar|contacts|notepad)).)*$ http://example.one @status=301\n"
+    "^/alpha/bravo/[?]((?!action=(newsfeed|calendar|contacts|notepad)).)*$ https://redirect.com/ @status=301\n"
 ])
 
 ts.Disk.File(regex_remap2_conf_path, typename="ats:config").AddLines([