Skip to content

Fix #86: don't decode query, fragment and user info in uri-with-query - #87

Merged
borkdude merged 1 commit into
babashka:mainfrom
dylanpulver:fix-uri-with-query-raw-components
Sep 10, 2026
Merged

Fix #86: don't decode query, fragment and user info in uri-with-query#87
borkdude merged 1 commit into
babashka:mainfrom
dylanpulver:fix-uri-with-query-raw-components

Conversation

@dylanpulver

Copy link
Copy Markdown
Contributor

Fixes #86.

uri-with-query rebuilds the URI string from .getRawPath (fixed in #68) but from the decoded .getAuthority, .getQuery and .getFragment, so percent-escapes outside the path are lost whenever :query-params are used. Against a local echo server, (http/get ".../search?q=a%26b" {:query-params {"page" 2}}) sends /search?q=a&b&page=2 — one parameter silently becomes two; without :query-params the same URL sends /search?q=a%26b. %2B becomes +, and %20 in the query or fragment throws URISyntaxException before anything is sent.

So: the remainder of #68, three more getters moved to their Raw siblings. The adjacent (comment ...) block's stale values are fixed too.

Rejected alternative: rebuild with the multi-arg java.net.URI constructor and let it re-encode. It leaves %26/%2B broken, re-breaks the #68 path fix, and double-encodes the new query (q=%26mooq=%2526moo), failing the existing test — what the docstring already warns about.

bb test:clj :clj-all + bb test:bb: 128 assertions on main, 132 here, 0 failures both; all four new ones fail on main. clj-kondo unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo

…th-query

babashka#68 changed the path component to `.getRawPath`, but the authority,
query and fragment were left on the decoded getters, so any
percent-escape outside the path is lost once `:query-params` are used:
`?q=a%26b` goes out as `?q=a&b` (one parameter becomes two), `%2B`
becomes `+`, and `%20` in the query or fragment throws
URISyntaxException before the request is sent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo
@borkdude
borkdude merged commit d0252f4 into babashka:main Sep 10, 2026
3 checks passed
@borkdude

Copy link
Copy Markdown
Contributor

Thanks!

borkdude added a commit that referenced this pull request Sep 10, 2026
…#87)

query and fragment were left on the decoded getters, so any
percent-escape outside the path is lost once `:query-params` are used:
`?q=a%26b` goes out as `?q=a&b` (one parameter becomes two), `%2B`
becomes `+`, and `%20` in the query or fragment throws
URISyntaxException before the request is sent.

Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Existing query, fragment and user info are decoded when :query-params are used

2 participants