You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/07/09 07:30:26 UTC

[GitHub] [incubator-apisix] moonming commented on a change in pull request #1816: bugfix: symbol would be encoded to 0x3f when using proxy-rewrite directive

moonming commented on a change in pull request #1816:
URL: https://github.com/apache/incubator-apisix/pull/1816#discussion_r452018348



##########
File path: apisix/plugins/proxy-rewrite.lua
##########
@@ -153,10 +154,20 @@ function _M.rewrite(conf, ctx)
         end
     end
 
-    upstream_uri = core.utils.uri_safe_encode(upstream_uri)
+    local index = find_str(upstream_uri, "?", 1, true)
+    if index then
+        upstream_uri = core.utils.uri_safe_encode(sub_str(upstream_uri, 1, index-1)) ..
+                       sub_str(upstream_uri, index)
+    else
+        upstream_uri = core.utils.uri_safe_encode(upstream_uri)
+    end
 
     if ctx.var.is_args == "?" then
-        ctx.var.upstream_uri = upstream_uri .. "?" .. (ctx.var.args or "")
+        if index then
+            ctx.var.upstream_uri = upstream_uri .. "&" .. (ctx.var.args or "")

Review comment:
       I'm wondering if we need to keep the request args?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org