api7 / lua-resty-radixtree

Adaptive Radix Trees implemented in Lua / LuaJIT
https://api7.ai/
Apache License 2.0
257 stars 61 forks source link

bug: parameter in path matching fails on percent encoding in the URI #148

Open Gary-Airwallex opened 3 months ago

Gary-Airwallex commented 3 months ago

When APISIX calls dispatch it sends Nginx normalized URI which decodes percent encoded characters, i.e. /uri%20contains%20space would become /uri contains space. The matching behavior of radixtree should be aware of this decoding. Steps to reproduce

  1. Create a new matching rule with a parameter in path
    {
    paths = { "/test/:id/update" },
    methods = { "GET" },
    }
  2. Match the rule with an URI that contains space, e.g. /test/contains space/update
  3. The URI is expected to match the parameter :id but it does not.
xpicio commented 1 month ago

Hello, the same issue occurs when the encoded character is the /, for example /machines/rando-id/messages/machine%2F01%2Ffeed-rate with the route path /machines/:id/channels/:channel is not work as expected.

lcaiffa commented 1 month ago

I have also gone crazy on the subject! It would be very important to correct this behavior!