openresty / openresty/lua-nginx-module
The return result of ngx.escape_uri() is inconsistent with the document description
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
As README says, the parenthesis ( ) should be encoded to %28 %29 as the default type, but actually it does not works fine(see figure 1, 2).
Since v0.10.16, this function accepts an optional type argument. It accepts the following values (defaults to 2):
0: escapes str as a full URI. And the characters (space), #, %, ?, 0x00 ~ 0x1F, 0x7F ~ 0xFF will be escaped.
2: escape str as a URI component. All characters except alphabetic characters, digits, -, ., _, ~ will be encoded as %XX.
And I found the result of ngx.escape_uri running under type 0 also does not match the result of the built-in encodeURI() in JavaScript(see figure 2, 3).
Environment
-
ngx.config.nginx_version = 1021004
-
ngx.config.ngx_lua_version = 10021
Figure 1 (a.lua)

Figure 2

Figure 3

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the documented behavior of ngx.escape_uri() for type 2 and comparing type 0 with JavaScript's encodeURI(), using the README description and the reported nginx and lua-nginx-module versions. Done means the function's results match the documented escaping rules, with the observed cases covered by a regression check or clarified documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100