oscerd opened a new pull request, #27428: URL: https://github.com/apache/camel/pull/27428
_Claude Code on behalf of oscerd_ [CAMEL-25345](https://issues.apache.org/jira/browse/CAMEL-25345), a follow-up to CAMEL-25188 (#27131). After #27131, the fast normalizer form-encodes the whole query when a key or value needs a percent escape (`=` or `#` in a value). The result then has a `%`, so normalizing it again goes to the complex normalizer. That one also encodes the path: a `#` becomes `%23`, and every `@` but the last in the user info becomes `%40`. The fast normalizer copies the path as is, so the path changed on the second normalization: | URI | normalized once | normalized twice | |---|---|---| | `sql:select+*+from+orders+where+id=:#id?dataSource=#ds` | `…where+id=:#id?dataSource=%23ds` | `…where+id=:%23id?dataSource=%23ds` | | `sftp://[email protected]@sftp.example.com/inbox?password=pa=ss` | `sftp://[email protected]@…?password=pa%3Dss` | `sftp://me%40example.com@…?password=pa%3Dss` | With a user like `[email protected]`, `getEndpoint(endpoint.getEndpointUri())` then created a second endpoint, and `hasEndpoint(...)` returned null. 4.22.1 found the cached one. With this PR, when the fast normalizer needs a percent escape, `normalizeUri` normalizes the whole uri with the complex normalizer, as for a uri that is already percent-encoded. This replaces the query-only re-encode from #27131, which produced the same query. The path now gets `%23` or `%40` on the first normalization, so the second one keeps it. A side effect: the ftp and sftp components read the host and user through `java.net.URI`, which can't parse a raw `@` in the user. With this change, `sftp://[email protected]@sftp.example.com/inbox?password=pa=ss` gets host `sftp.example.com` and user `[email protected]`. On main and on 4.22.1 both were null. When no value needs an escape, the fast normalizer still keeps the raw `@`, as in every release. That part is unchanged. ### Checks - Local fuzz test, 600,000 random endpoint uris against camel-4.22.1: every uri normalizes to itself, and the remaining path and query values a default component gets are the same as on 4.22.1. This is the re-run CAMEL-25345 asked for. - Against current main, 600,000 more: the only differences are `%23` and `%40` in the path, the query is the same, and no uri throws that didn't before. - No existing test in the repository uses a uri whose normalized form this changes (I scanned the test sources). - `URISupportTest`: a new `testNormalizePathWhenQueryNeedsPercentEscape`, and three uris added to `testNormalizeTwiceGivesTheSameUri`. Both fail on main. - camel-util: 295 tests. camel-core URI, endpoint, intercept, placeholder, recipient list and `toD` tests: 780. Full `mvn clean install -DskipTests -DskipITs`. The CAMEL-24524 note in the 4.23 upgrade guide is updated too. It said the query is now "consistently" unencoded, which isn't true once it's form-encoded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
