Skip to content

fix: preserve unrecognized %XX sequences in safeDecodeURIComponent#426

Draft
deepview-autofix wants to merge 1 commit into
delvedor:mainfrom
deepview-autofix:deepview/8124660e54
Draft

fix: preserve unrecognized %XX sequences in safeDecodeURIComponent#426
deepview-autofix wants to merge 1 commit into
delvedor:mainfrom
deepview-autofix:deepview/8124660e54

Conversation

@deepview-autofix
Copy link
Copy Markdown

decodeComponentChar returns null for percent-encoded sequences that are not reserved characters. Previously, safeDecodeURIComponent concatenated this null directly, producing the literal string "null" in the decoded output (e.g. a double-encoded %2520 became "null" after safeDecodeURI/safeDecodeURIComponent). Fall back to the original %XX substring when decoding is not applicable.

`decodeComponentChar` returns `null` for percent-encoded sequences that
are not reserved characters. Previously, `safeDecodeURIComponent`
concatenated this `null` directly, producing the literal string `"null"`
in the decoded output (e.g. a double-encoded `%2520` became `"null"`
after `safeDecodeURI`/`safeDecodeURIComponent`). Fall back to the
original `%XX` substring when decoding is not applicable.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
@deepview-autofix deepview-autofix marked this pull request as draft April 19, 2026 23:23
Copy link
Copy Markdown
Author

@deepview-autofix deepview-autofix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft, see comment below

Copy link
Copy Markdown

@ChALkeR ChALkeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of this one, I'm unsure

One one hand, safeDecodeURI is documented to preserve chars:

* Safely decodes a URI path, preserving reserved characters in querystring.

On the other hand, there is a test that expects "null" string in output:

t.assert.equal(safeDecodeURIComponent('Hello%3xWorld'), 'HellonullWorld')

That test was introduced in #330 though and could have been not by design but by documenting existing behavior / increasing coverage.

But anyway, the behavior should be either documented if it is by design or fixed if it's a bug

While this PR assumes the latter, it could be the former - not sure

@mcollina
Copy link
Copy Markdown
Collaborator

The test was only added to increase coverage, I think should be fixed

@deepview-autofix deepview-autofix marked this pull request as ready for review April 21, 2026 01:35
@deepview-autofix deepview-autofix marked this pull request as draft April 21, 2026 01:41
@ChALkeR
Copy link
Copy Markdown

ChALkeR commented Apr 21, 2026

Will recheck the logic behind decoding one more time as a safety measure

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