fix non-ASCII filename mangling caused by NBSP in page titles#1930
Open
Self-Perfection wants to merge 1 commit into
Open
fix non-ASCII filename mangling caused by NBSP in page titles#1930Self-Perfection wants to merge 1 commit into
Self-Perfection wants to merge 1 commit into
Conversation
Firefox's browser.downloads.download() rejects filenames containing NBSP (U+00A0) and narrow NBSP (U+202F) with "illegal characters", even though both are valid on every modern filesystem and accepted by Chromium (see https://bugzilla.mozilla.org/show_bug.cgi?id=2030811). The existing catch-block in download-util.js had a fallback that replaced ALL non-ASCII runs with the replacement character on any "illegal characters" error — so a single invisible NBSP from typographic markup would silently destroy the entire Cyrillic/CJK/ Arabic filename. Add a targeted retry branch (before the legacy non-ASCII strip) that handles six specific codepoints rejected by browser engines: - U+00A0 NBSP, U+202F narrow NBSP → replaced with regular space - U+00AD soft hyphen, U+200B ZWSP, U+FEFF BOM, U+2060 word joiner → removed The first two are Gecko-specific rejections; the other four are rejected by both Gecko and Chromium. On Chromium the new branch never fires (no error is thrown), so behavior is unchanged. Minimal repro (save via SingleFile on Firefox): <title>Pies w łóżku</title> Before: "Pies w_ku (...).html" (ł ó ż eaten by non-ASCII strip) After: "Pies w łóżku (...).html" (NBSP → space, Polish letters intact) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Firefox's browser.downloads.download() rejects filenames containing NBSP (U+00A0) and narrow NBSP (U+202F) with "illegal characters", even though both are valid on every modern filesystem and accepted by Chromium (see https://bugzilla.mozilla.org/show_bug.cgi?id=2030811).
The existing catch-block in download-util.js had a fallback that replaced ALL non-ASCII runs with the replacement character on any "illegal characters" error — so a single invisible NBSP from typographic markup would silently destroy the entire Cyrillic/CJK/ Arabic filename.
Add a targeted retry branch (before the legacy non-ASCII strip) that handles six specific codepoints rejected by browser engines:
The first two are Gecko-specific rejections; the other four are rejected by both Gecko and Chromium. On Chromium the new branch never fires (no error is thrown), so behavior is unchanged.
Minimal repro (save via SingleFile on Firefox):
<title>Pies w łóżku</title>Before: "Pies w_ku (...).html" (ł ó ż eaten by non-ASCII strip)
After: "Pies w łóżku (...).html" (NBSP → space, Polish letters intact)