CLARIN-DSpace v9/Port #1368 (RFC 5987 Content-Disposition on allzip + by-handle download) to the v9 base - #1428
Merged
Conversation
…for single-file + allzip download (#1368) Source: a3627a6 (dtq-dev PR #1368) All three download endpoints now emit exactly one RFC 5987 Content-Disposition header, `attachment; filename="<ASCII fallback>"; filename*=UTF-8''<percent-encoded>`, with the ASCII fallback produced by NFD transliteration (not underscore substitution) and with `\` and `"` escaped so a name containing a quote cannot close the quoted-string early. - HttpHeadersInitializer (single-file, /api/core/bitstreams/{uuid}/content): dtq-dev-9-base is byte-identical with vanilla 9.3 here, so the RFC 5987 rewrite of the source commit is already present. Only the deliberate deviation from vanilla was ported: the two `.replace("\\", "\\\\")` / `.replace("\"", "\\\"")` calls in createFallbackAsciiName. `javax.mail` MimeUtility was NOT reintroduced -- vanilla 9.3 already dropped it. - MetadataBitstreamController (CLARIN allzip) and BitstreamByHandleRestController (CLARIN by-handle) are fork-only; both hunks applied verbatim. allzip stops building a bare `attachment;filename="<name>"`; by-handle stops replacing non-ASCII with `_` and transliterates instead. - Tests: three expectation strings updated in BitstreamByHandleRestControllerIT ("M_di_ (3).jfif" -> "Media (3).jfif", "___.txt" -> ".txt", "M_di_ (+)#9) ano" -> "Media (+)#9) ano"); testBitstreamNameWithQuote added to BitstreamRestControllerIT; downloadAllZipWithDoubleQuotesInItemName and downloadAllZipWithNonAsciiItemName added to MetadataBitstreamControllerIT (1 -> 3 tests), which exists on this branch since #1425. Deviations from the source commit, both because dtq-dev-9-base already carries the vanilla 9.3 form: - HttpHeadersInitializer: 3 added / 1 removed line instead of 52 / 4. - BitstreamRestControllerIT: the `MimeUtility` import removal and the rewrite of the diacritics test to the RFC 5987 expectation are already on the branch; only the continuation-indent fix of expectedUtf8Encoded and the new testBitstreamNameWithQuote were applied (44 added / 3 removed instead of 49 / 3). Co-authored-by: JohnnyMendesC <177888064+JohnnyMendesC@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <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.
References
Card BE-01 (tranche T1/T2) of the
dtq-dev→dtq-dev-9-basesync — port of dtq-dev PR #1368 (a3627a6817).Depends on #1425, which restored
MetadataBitstreamControllerIT.Description
Downloading a file whose name carries diacritics, quotes or a backslash must return one valid
Content-Disposition: attachment; filename="<ASCII fallback>"; filename*=UTF-8''<percent-encoded>header onall three endpoints: vanilla single-file (
/api/core/bitstreams/{uuid}/content), CLARIN allzip(
MetadataBitstreamController) and CLARIN by-handle (BitstreamByHandleRestController).The ASCII fallback is an NFD transliteration, not underscore substitution, and it escapes
\and"—a deliberate deviation from vanilla, carried over from the source PR.
v9 adaptations
HttpHeadersInitializer.javaon the base equals vanilla 9.3, which already implements RFC 5987. Only the two.replace("\\", "\\\\").replace("\"", "\\\"")calls insidecreateFallbackAsciiNamewere taken;javax.mailMimeUtilitywas not reintroduced. Net numstat 3/1 against the source's 52/4 — the 49-line gap is exactlywhat vanilla already covers.
Two corrections to the card's stated expectations, both verified rather than assumed:
HttpHeadersInitializer;BitstreamRestControllerITconflicts too (2 hunks)BitstreamByHandleRestControlleras MISSING; it is PARTIAL — it already emittedfilename*=UTF-8''and already escaped\and". Only the_-substitution fallback was pre-fix, and thatis what this change replaces with the NFD transliteration.
Instructions for Reviewers
Every count was read from the per-class failsafe report file, not the console line, and report freshness was
checked by mtime after
clean— so the documented "Tests run: 0 with BUILD SUCCESS" trap is excluded.Guards: X1 blob join over every touched file → 0 vanilla-identical candidates. X2 → 0. No migrations, no config keys.
[live]verification (uploadPříliš žluťoučký kůň "test".txtand check the header on all three endpoints)happens after merge and deploy on dev-6:8603.
Checklist
Source:
a3627a6817(dtq-dev PR #1368) · card BE-01.🤖 Generated with Claude Code