spacewander commented on code in PR #7401:
URL: https://github.com/apache/apisix/pull/7401#discussion_r918601678


##########
docs/en/latest/plugins/proxy-rewrite.md:
##########
@@ -33,14 +33,15 @@ The `proxy-rewrite` Plugin rewrites Upstream proxy 
information such as `scheme`,
 
 ## Attributes
 
-| Name      | Type          | Required | Default | Valid values                
                                                                                
                           | Description                                        
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
          |
-|-----------|---------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| scheme    | string        | False    | "http"  | ["http", "https"]           
                                                                                
                           | New upstream protocol scheme. This option is 
deprecated. Instead, it is recommended to set the `scheme` field in the 
Upstream.                                                                       
                                                                                
                                                                                
                                                                                
                        |
-| uri       | string        | False    |         |                             
                                                                                
                           | New Upstream forwarding address. Value supports 
[Nginx variables](https://nginx.org/en/docs/http/ngx_http_core_module.html). 
For example, `$arg_name`.                                                       
                                                                                
                                                                                
                                                                                
                |
-| method    | string        | False    |         | ["GET", "POST", "PUT", 
"HEAD", "DELETE", "OPTIONS","MKCOL", "COPY", "MOVE", "PROPFIND", 
"PROPFIND","LOCK", "UNLOCK", "PATCH", "TRACE"] | Rewrites the HTTP method.      
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              |
-| regex_uri | array[string] | False    |         |                             
                                                                                
                           | New upstream forwarding address. Regular 
expressions can be used to match the URL from client. If it matches, the URL 
template is forwarded to the Upstream otherwise, the URL from the client is 
forwarded. When both `uri` and `regex_uri` are configured, `uri` is used first. 
For example, `[" ^/iresty/(.*)/(.*)/(.*)", "/$1-$2-$3"]`. Here, the first 
element is the regular expression to match and the second element is the URL 
template forwarded to the Upstream. |
-| host      | string        | False    |         |                             
                                                                                
                           | New Upstream host address.                         
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
          |
-| headers   | object        | False    |         |                             
                                                                                
                           | New Upstream headers. Headers are overwritten if 
they are already present otherwise, they are added to the present headers. To 
remove a header, set the header value to an empty string. The values in the 
header can contain Nginx variables like `$remote_addr` and `$client_addr`.      
                                                                                
                                                                                
                  |
+| Name                        | Type          | Required | Default | Valid 
values                                                                          
                                                 | Description                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                |
+|-----------------------------|---------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| scheme                      | string        | False    | "http"  | ["http", 
"https"]                                                                        
                                              | New upstream protocol scheme. 
This option is deprecated. Instead, it is recommended to set the `scheme` field 
in the Upstream.                                                                
                                                                                
                                                                                
                                                                                
                               |
+| uri                         | string        | False    |         |           
                                                                                
                                             | New Upstream forwarding address. 
Value supports [Nginx 
variables](https://nginx.org/en/docs/http/ngx_http_core_module.html). For 
example, `$arg_name`.                                                           
                                                                                
                                                                                
                                                                                
            |
+| method                      | string        | False    |         | ["GET", 
"POST", "PUT", "HEAD", "DELETE", "OPTIONS","MKCOL", "COPY", "MOVE", "PROPFIND", 
"PROPFIND","LOCK", "UNLOCK", "PATCH", "TRACE"] | Rewrites the HTTP method.      
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              |
+| regex_uri                   | array[string] | False    |         |           
                                                                                
                                             | New upstream forwarding address. 
Regular expressions can be used to match the URL from client. If it matches, 
the URL template is forwarded to the Upstream otherwise, the URL from the 
client is forwarded. When both `uri` and `regex_uri` are configured, `uri` is 
used first. For example, `[" ^/iresty/(.*)/(.*)/(.*)", "/$1-$2-$3"]`. Here, the 
first element is the regular expression to match and the second element is the 
URL template forwarded to the Upstream. |
+| host                        | string        | False    |         |           
                                                                                
                                             | New Upstream host address.       
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                            |
+| headers                     | object        | False    |         |           
                                                                                
                                             | New Upstream headers. Headers 
are overwritten if they are already present otherwise, they are added to the 
present headers. To remove a header, set the header value to an empty string. 
The values in the header can contain Nginx variables like `$remote_addr` and 
`$client_addr`.                                                                 
                                                                                
                                       |
+| use_real_request_uri_unsafe | boolean       | False    | false   |           
                                                                                
                                             | Use real_request_uri (originally 
request_uri in nginx) to bypass URI normalization. **Enabling this is 
considered unsafe as it bypasses all URI normalization steps**.                 
                                                                                
                                                                                
                                                                                
                                    |

Review Comment:
   ```suggestion
   | use_real_request_uri_unsafe | boolean       | False    | false   |         
                                                                                
                                               | Use real_request_uri (original 
$request_uri in nginx) to bypass URI normalization. **Enabling this is 
considered unsafe as it bypasses all URI normalization steps**.                 
                                                                                
                                                                                
                                                                                
                                    |
   ```



##########
t/plugin/proxy-rewrite3.t:
##########
@@ -200,3 +200,103 @@ passed
 GET /hello
 --- error_log
 plugin_proxy_rewrite get method: POST
+
+
+
+=== TEST 8: set route(unsafe uri not normalized at request)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "methods": ["GET"],
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "use_real_request_uri_unsafe": true
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/print_uri_detailed"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request

Review Comment:
   We can remove `--- request` & `--- no_error_log` as they are already defined 
at the top
   
https://github.com/apache/apisix/blob/11bba0059c2a714486315c7beaf886eddd75ba60/t/plugin/proxy-rewrite3.t#L28-L34



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to