Skip to content

Encode escapeuri byte by byte so it resolves under --trim - #77

Merged
quinnj merged 1 commit into
JuliaWeb:masterfrom
asinghvi17:escapeuri-trim
Sep 3, 2026
Merged

Encode escapeuri byte by byte so it resolves under --trim#77
quinnj merged 1 commit into
JuliaWeb:masterfrom
asinghvi17:escapeuri-trim

Conversation

@asinghvi17

@asinghvi17 asinghvi17 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

escapeuri(::AbstractString, ::Function) builds its result with join over a generator, which routes through Base.AnnotatedString — a path --trim cannot resolve. One call to escapeuri on a String fails a juliac --experimental --trim=safe build with 20 verifier errors.

A byte loop appending to a Vector{UInt8} does the same job and resolves.

Measured on Julia 1.12.7:

  • Output is identical. 1,202,368 comparisons against the v1.7.0 implementation, zero mismatches.

  • Verifier errors 20 → 0. A @main calling escapeuri("hello world/foo?a=1&b=ü") now builds with juliac --output-exe --experimental --trim=safe and prints the right answer; so do programs calling escapepath and a custom predicate.

  • Tests pass, 304/304, including two new assertions for the safe argument, which had none.

  • Faster (@btime):

    input v1.7.0 here
    205-byte query string 4.97 µs, 16.1 KiB 796 ns, 1.25 KiB
    88-byte path via escapepath 979 ns, 448 B 345 ns, 256 B
    "hello world" 291 ns, 592 B 56 ns, 176 B

Made by Claude

`join` over a generator routes through `Base.AnnotatedString`, which
`juliac --trim=safe` cannot resolve: one `escapeuri(::String)` call costs
20 verifier errors. A byte loop over the same safe set produces identical
output for every input, and is 3-6x faster.
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.02%. Comparing base (859a10c) to head (bb3eb3d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #77      +/-   ##
==========================================
+ Coverage   86.91%   87.02%   +0.11%     
==========================================
  Files           5        5              
  Lines         382      393      +11     
==========================================
+ Hits          332      342      +10     
- Misses         50       51       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quinnj
quinnj merged commit 0cd5252 into JuliaWeb:master Sep 3, 2026
11 checks passed
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.

3 participants