Closed Bug 1778429 Opened 3 years ago Closed 3 years ago

Half-width kana filenames are corrupted when saving

Categories

(Firefox :: File Handling, defect, P2)

Firefox 102
defect

Tracking

()

VERIFIED FIXED
105 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox-esr102 104+ verified
firefox102 --- wontfix
firefox103 --- wontfix
firefox104 + verified
firefox105 + verified

People

(Reporter: note6673, Assigned: enndeakin)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0

Steps to reproduce:

  1. Access to the test file with half-width katakana in the filename https://pastebin.com/QJSFnU4Z on Firefox 102
  2. Click the "download"

Alternative flow:

  1. Access to the test file with half-width katakana in the filename https://pastebin.com/QJSFnU4Z on Firefox 102
  2. Ctrl + S

Actual results:

Downloaded filenames are "test_ ス _TEST_テスト.txt".

Expected results:

Downloaded filenames are "test_テスト_TEST_テスト.txt".

This bug is not reproduced in firefox 101.0.1.
I believe this is due to bug 1746052.

Component: Untriaged → File Handling
Regressed by: 1746052

Set release status flags based on info from the regressing bug 1746052

:enndeakin, since you are the author of the regressor, bug 1746052, could you take a look?
For more information, please visit auto_nag documentation.

Flags: needinfo?(enndeakin)

[Tracking Requested - why for this release]:Half-width kana filenames are corrupted when saving

I can reproduce the issue on Nightly104.0a1 , Firefox 103.0b5, 102.0.1, 102.0esr Windows10.

Status: UNCONFIRMED → NEW
Has STR: --- → yes
Ever confirmed: true

This is because FILE_ILLEGAL_CHARACTERS is a single-byte string but is being compared using a utf16 string.

Assignee: nobody → enndeakin
Severity: -- → S3
Status: NEW → ASSIGNED
Flags: needinfo?(enndeakin)

It is likely that 1772006 will fix this.

Depends on: 1772006

Please consider escalating severity because Bug 1778880 has no workaround.
In WebExtension, an add-on controls the filename then a user cannot fix the filename and just get a error that the file cannot be saved.

Note this validation bug is not limited to half-width kana, some other examples being rejected by downloads.download() are U+00A0 (no-break space) and 🏴‍☠️ (Pirate flag)

Nika, are the patches in bug 1772006 likely to reland soon?

Neil, is there a more short-term solution we could employ here?

Flags: needinfo?(nika)
Flags: needinfo?(enndeakin)
Priority: -- → P2

A short-term fix is to make utf16 copies of FILE_ILLEGAL_CHARACTERS and other constants that are used.

Flags: needinfo?(enndeakin)

(In reply to :Gijs (he/him) from comment #9)

Nika, are the patches in bug 1772006 likely to reland soon?

I haven't had the time to properly rebase & then fix any bitrot issues on them yet, so I don't know how much work that's going to be to get them 100% ready to land. I can try to up the priority a bit though - it's been at the back of my todo list for a while

That being said, I don't entirely know how my patches from that bug will fix any issues here, as I don't remember changing the semantics of any methods around FILE_ILLEGAL_CHARACTERS in my patches (as the existing code does utf-16 character-by-character replacements, even when passed narrow strings IIRC).

Flags: needinfo?(nika)
Pushed by neil@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e0b4c0e343ef use utf-16 character literals when calling ReplaceChar in SanitizeFileName, r=Gijs
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch

The patch landed in nightly and beta is affected.
:enndeakin, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox104 to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(enndeakin)

Comment on attachment 9286919 [details]
Bug 1778429, use utf-16 character literals when calling ReplaceChar in SanitizeFileName, r=gijs

Beta/Release Uplift Approval Request

  • User impact if declined: Broken filename sanitization
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: See comment 0 and the dupe.
  • List of other uplifts needed: bug 1779128 (or resolve conflicts)
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): 2-line change with automated test coverage
  • String changes made/needed: No
  • Is Android affected?: Unknown
Attachment #9286919 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Flags: needinfo?(enndeakin)
Depends on: 1779128
No longer depends on: 1772006

Note that the patch as is won't apply without 1779128.

(In reply to Neil Deakin from comment #18)

Note that the patch as is won't apply without 1779128.

Sorry! Updated the beta approval request.

Comment on attachment 9286919 [details]
Bug 1778429, use utf-16 character literals when calling ReplaceChar in SanitizeFileName, r=gijs

Approved for 104.0b3

Attachment #9286919 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

Reproduced the issue using an old Nightly from 2022-07-06, verified that this issue is fixed using the steps from comment 0 and using Download All add-on (no error saying that the characters are invalid) on Latest Nightly 105.0a1 and Firefox 104.0b3 across platforms (Windows 10, macOS 11.6 and Ubuntu 18.04). Leaving the status to RESOLVED until the patch reaches ESR as well.

Please nominate this for ESR102 approval when you're comfortable doing so. It grafts cleanly.

Flags: needinfo?(enndeakin)

Comment on attachment 9286919 [details]
Bug 1778429, use utf-16 character literals when calling ReplaceChar in SanitizeFileName, r=gijs

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Some pages containing certain characters (typically japanese characters) aren't sanitized properly when saving/dragging to desktop
  • User impact if declined: File not saved correctly
  • Fix Landed on Version: 104
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Minor fix to handle UTF16 characters correctly.
Flags: needinfo?(enndeakin)
Attachment #9286919 - Flags: approval-mozilla-esr102?

Comment on attachment 9286919 [details]
Bug 1778429, use utf-16 character literals when calling ReplaceChar in SanitizeFileName, r=gijs

Approved for 102.2esr.

Attachment #9286919 - Flags: approval-mozilla-esr102? → approval-mozilla-esr102+

Also verified this is fixed using latest esr102 build from treeherder (https://treeherder.mozilla.org/jobs?repo=mozilla-esr102&tochange=18fa1f585ac2f5d0c1d620581814df29d3267db8&fromchange=f95a172405adace8207bd40df4643fab779255f3) across platforms (Windows 10 64bit, macOS 11.6 and Ubuntu 18.04).

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: