Repository navigation
Fix filename parsing for RFC 5987 Content-Disposition headers - #3492
Merged
beganovich merged 6 commits intoNov 30, 2026
Merged
beganovich merged 6 commits into
beganovich merged 6 commits into
Conversation
The invoice PDF and e-invoice download hooks split the header on "filename=", so a header such as attachment; filename=_0354.pdf; filename*=utf-8''%E8%AB%8B... produced "0354.pdf; filename*=utf-8''..." as the download name. Use the shared extractFilenameFromHeaders() helper, and make its filename* regex case-insensitive so the lowercase utf-8'' sent by Symfony is decoded. Fixes invoiceninja/invoiceninja#10189
Accept filename*=UTF-8'<lang>'<value> and return an empty string instead of throwing when decodeURIComponent sees malformed percent-encoding.
A malformed percent-encoded filename* should not discard a valid ASCII filename= fallback. Exclude filename* from the fallback regex so a header without an ASCII name still returns an empty string.
Replace the duplicated blob/link/click sequence with downloadBlob(), which also revokes the object URL.
beganovich
force-pushed
the
10189-content-disposition-filename
branch
from
November 30, 2026 10:25
8a23d75 to
559b9c1
Compare
Member
|
Thanks 👍 |
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.
Summary
The invoice PDF and e-invoice download hooks split the
Content-Dispositionheader onfilename=, so a header such asproduced
0354.pdf; filename*=utf-8''...as the download name. The shared helper also missed the lowercaseutf-8''that Symfony emits.Change
src/common/helpers/download.tsfilename*regex case-insensitive and tolerate whitespace around=.src/pages/invoices/common/hooks/useDownloadPdf.tssrc/pages/invoices/common/hooks/useDownloadEInvoice.tsextractFilenameFromHeaders()anddownloadBlob()helpers instead of splitting onfilename=and hand-rolling the blob download.tests/unit/helpers/download.test.tsVerification
npx tsc --noEmitandnpx biome checkpass on the changed files.Fixes invoiceninja/invoiceninja#10189.
This PR was prepared with AI assistance (Claude) and reviewed and tested locally. I am an open-source lover with a high token budget; if this is not the right approach, please reject it or improve it. Thanks for understanding.