Skip to content

Preserve caller strings when repairing URI paths - #96

Open
OskarEichler wants to merge 2 commits into
sparklemotion:masterfrom
OskarEichler:codex/preserve-uri-parser-input
Open

Preserve caller strings when repairing URI paths#96
OskarEichler wants to merge 2 commits into
sparklemotion:masterfrom
OskarEichler:codex/preserve-uri-parser-input

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Duplicate the input string only on the URI-repair fallback before replacing its path. Strictly valid URI inputs retain their existing fast path.

Reproduction and verification

Parsing a mutable https://example.org/a[] changes the caller string to an escaped form; a frozen equivalent raises FrozenError. Four original ownership cases and 17 extended cases cover frozen/mutable paths, query/fragment preservation and an invalid URI.

Verified this patch independently on master with Ruby 4.0.6 and SQLite3 2.9.6: existing rake test suite 144 tests, 2,870 assertions, zero failures/errors. Targeted syntax and git diff --check pass. Comparative RuboCop Lint adds no offenses (baseline 40; cleanup patch removes one). This repository does not configure a Ruby lint suite, so the comparison is supplementary, not a claim of clean full lint.

Focused checks are external scratch scripts. No repository tests were added or modified because this contribution's task explicitly prohibits test-file changes. All data is synthetic; SQLite checks use temporary/in-memory local databases. Other Ruby versions and upstream CI are not locally verified. Runtime source at installed v1.1.6 is identical apart from its version constant; consumer backports will retain that release instead of adopting the unreleased version/Ruby requirement.

Compatibility / breaking changes

No API changes. Parsing no longer mutates caller-owned strings, and frozen repairable URLs work. The returned URI still retains the original relaxed path; invalid URLs still raise.

@OskarEichler
OskarEichler requested a review from knu as a code owner August 27, 2026 18:54
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.

1 participant