You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/01/09 13:56:43 UTC

[GitHub] [incubator-shenyu] qicz commented on a change in pull request #2738: [type: refactor] optimize & fix uri with invalid char.

qicz commented on a change in pull request #2738:
URL: https://github.com/apache/incubator-shenyu/pull/2738#discussion_r780784899



##########
File path: shenyu-plugin/shenyu-plugin-uri/src/main/java/org/apache/shenyu/plugin/uri/URIPlugin.java
##########
@@ -42,27 +42,18 @@
         if (StringUtils.isBlank(path)) {
             return chain.execute(exchange);
         }
-        String rewriteURI = (String) exchange.getAttributes().get(Constants.REWRITE_URI);
+        String rewriteUri = (String) exchange.getAttributes().get(Constants.REWRITE_URI);
         URI uri = exchange.getRequest().getURI();
-        if (StringUtils.isNoneBlank(rewriteURI)) {
-            path = path + rewriteURI;
+        if (StringUtils.isNoneBlank(rewriteUri)) {
+            path = path + rewriteUri;
         } else {
             String realUrl = shenyuContext.getRealUrl();
             if (StringUtils.isNoneBlank(realUrl)) {
                 path = path + realUrl;
             }
         }
-        URI realURI;
-        if (StringUtils.isNotEmpty(uri.getRawQuery()) && uri.getRawQuery().contains("%")) {
-            path = String.join("?", path, uri.getRawQuery());
-            realURI = UriComponentsBuilder.fromHttpUrl(path).build(true).toUri();
-        } else {
-            if (StringUtils.isNotEmpty(uri.getQuery())) {
-                path = String.join("?", path, uri.getQuery());
-            }
-            realURI = UriComponentsBuilder.fromHttpUrl(path).build(false).toUri();
-        }
-        exchange.getAttributes().put(Constants.HTTP_URI, realURI);
+        URI realUri = URI.create(path + "?" + RequestQueryCodecUtil.getCodecQuery(exchange));

Review comment:
       some query like `status=[abc%2Cedf]` will catch the `Invalid character '[' for QUERY_PARAM in status=[abc%2Cedf]`




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

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