bosprimigenious opened a new issue, #1073:
URL: https://github.com/apache/dubbo-go-pixiu/issues/1073
## Description
`stringutil.GetTrieKey` handles absolute URLs (as demonstrated by the
existing trie tests), but a valid absolute URL without an explicit path is
treated as a path containing its host. Query characters are also inspected
before the query is removed, allowing a slash or another URL in the query to
change the route key.
Reproduced on unchanged `develop` at
`51198ddd8d1317f6c1d7e351fde8a6be7da60d62`, Go 1.25.14 / macOS arm64, unchanged
`go.mod` and `go.sum`.
```go
fmt.Println(stringutil.GetTrieKey("GET", "/"))
fmt.Println(stringutil.GetTrieKey("GET", "https://example.com"))
fmt.Println(stringutil.GetTrieKey("GET",
"https://example.com?next=/callback"))
fmt.Println(stringutil.GetTrieKey("GET",
"/api/users?next=https://example.com/callback"))
```
Actual:
```text
GET
GET/example.com
GET/callback
GET/callback
```
Expected:
```text
GET
GET
GET
GET/api/users
```
With the actual `trie.NewTrie()` containing root and `/callback` entries,
the second URL misses the root entry and the third selects the callback entry.
This reproduction exercises the exported key helper and real trie; it does
**not** establish an HTTP-server authorization bypass.
## Root cause / proposed change
The authority-removal code searches for a slash before excluding the query.
If there is no slash, `strings.Index` returns -1 and slicing from index 0
leaves the host intact. Removing a trailing slash before removing the query
also makes `/api/users/?x=1` differ from `/api/users/`.
Remove the query before examining authority/path delimiters and handle an
absent path explicitly, retaining the existing raw escaped-path and wildcard
representations.
New focused regression tests currently produce **10 failing / 9 passing leaf
cases** on the unchanged implementation, including actual trie lookup failures.
Existing trie tests pass. No fix or complete upstream acceptance is claimed yet.
AI disclosure: this issue text, investigation and executed reproduction were
prepared by OpenAI Codex under the account holder's instruction. No human
review is claimed.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]