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 2021/07/17 10:59:58 UTC

[GitHub] [apisix] jamesislebron opened a new issue #4619: bug: regex rules return true when value is `nil` and pattern is `[z-aA-Z0-9]{1,}`

jamesislebron opened a new issue #4619:
URL: https://github.com/apache/apisix/issues/4619


   ### Issue description
   
   regex rules return true when value is `nil` and pattern is `[z-aA-Z0-9]{1,}` 
   
   ### Environment
   
   
   * apisix version (cmd: `apisix version`): 2.1
   * OS (cmd: `uname -a`): centos 7
   * OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):  openresty/1.17.8.1
   * etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   * luarocks version, if the issue is about installation (cmd: `luarocks --version`): 2.3.0
   
   ### Minimal test code / Steps to reproduce the issue
   
   1. I added a rules for a route like this: 
   
   ```
   ["http_version", "~~", "[z-aA-Z0-9]{1,}"]
   ```
   
   2. I found that this request would  be caught by the route
   
   ```
   curl 127.0.0.1:9080/hello
   ```
   
   3. I tried to read source code and add log in it, found that there meybe a bug in `deps/share/lua/5.1/resty/expr/v1.lua` line 93 - 99 :
   ```
       ["~~"] = function (l_v, r_v)
           local from = re_find(l_v, r_v, "jo")
           core.log.warn("l_v: ", l_v, " r_v" ,r_v, "re_find res: ", from)
           if from then
               return true
           end
           return false
       end,
   ```
   ### What's the actual result? 
   when I use the request without header version, the l_v's value is nil , the r_v‘s value is what I set: `[z-aA-Z0-9]{1,}`
   the op is regex op `~~`, but ngx.re_find function return `true`, is this a bug ?
   logs:
   ![image](https://user-images.githubusercontent.com/20439714/126034496-d5d5e7f7-a38a-4cc9-a913-54c629b1d8fd.png)
   
   ### What's the expected:
   When I use the reqesut without the `version` header, the `compare_val` func should not return true, and it should not be caught by this route.
   


-- 
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@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #4619: bug: regex rules return true when value is `nil` and pattern is `[z-aA-Z0-9]{1,}`

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #4619:
URL: https://github.com/apache/apisix/issues/4619#issuecomment-881894873


   Please update apisix version to 2.7
   The code you pointed out has been fixed in the latest version
   Please refer to 
   https://github.com/api7/lua-resty-expr/blob/48925f4b9afa261d48317dc00834be1709d5dd83/lib/resty/expr/v1.lua#L115-L125


-- 
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@apisix.apache.org

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



[GitHub] [apisix] jamesislebron commented on issue #4619: bug: regex rules return true when value is `nil` and pattern is `[z-aA-Z0-9]{1,}`

Posted by GitBox <gi...@apache.org>.
jamesislebron commented on issue #4619:
URL: https://github.com/apache/apisix/issues/4619#issuecomment-881908290


   > Please update apisix version to 2.7
   > The code you pointed out has been fixed in the latest version
   > Please refer to
   > https://github.com/api7/lua-resty-expr/blob/48925f4b9afa261d48317dc00834be1709d5dd83/lib/resty/expr/v1.lua#L115-L125
   
    @tzssangglass 
    wow,已经看到,非常感谢🙏


-- 
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@apisix.apache.org

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



[GitHub] [apisix] jamesislebron closed issue #4619: bug: regex rules return true when value is `nil` and pattern is `[z-aA-Z0-9]{1,}`

Posted by GitBox <gi...@apache.org>.
jamesislebron closed issue #4619:
URL: https://github.com/apache/apisix/issues/4619


   


-- 
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@apisix.apache.org

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