Skip to content

CLARIN-DSpace v9/Port #1368 (RFC 5987 Content-Disposition on allzip + by-handle download) to the v9 base - #1428

Merged
milanmajchrak merged 1 commit into
dtq-dev-9-basefrom
ufal/port-1368-9-base
Sep 9, 2026
Merged

CLARIN-DSpace v9/Port #1368 (RFC 5987 Content-Disposition on allzip + by-handle download) to the v9 base#1428
milanmajchrak merged 1 commit into
dtq-dev-9-basefrom
ufal/port-1368-9-base

Conversation

@milanmajchrak

Copy link
Copy Markdown
Collaborator

References

Card BE-01 (tranche T1/T2) of the dtq-devdtq-dev-9-base sync — 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 on
all 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.java on the base equals vanilla 9.3, which already implements RFC 5987. Only the two
.replace("\\", "\\\\").replace("\"", "\\\"") calls inside createFallbackAsciiName were taken; javax.mail
MimeUtility was not reintroduced. Net numstat 3/1 against the source's 52/4 — the 49-line gap is exactly
what vanilla already covers.

Two corrections to the card's stated expectations, both verified rather than assumed:

  • the card predicts conflicts only in HttpHeadersInitializer; BitstreamRestControllerIT conflicts too (2 hunks)
  • the card marks BitstreamByHandleRestController as MISSING; it is PARTIAL — it already emitted
    filename*=UTF-8'' and already escaped \ and ". Only the _-substitution fallback was pre-fix, and that
    is what this change replaces with the NFD transliteration.

Instructions for Reviewers

mvn --no-transfer-progress -V clean install -P-assembly -DskipTests    BUILD SUCCESS, 15× "0 Checkstyle violations"
mvn -o -pl dspace-server-webapp verify -DskipIntegrationTests=false \
    -Dit.test=BitstreamByHandleRestControllerIT,BitstreamRestControllerIT,MetadataBitstreamControllerIT
      BitstreamByHandleRestControllerIT   16/0/0
      BitstreamRestControllerIT           40/0/0
      MetadataBitstreamControllerIT        3/0/0   (1 restored by #1425 + the 2 allzip tests added here)
git diff origin/dtq-dev-9-base HEAD | grep -c '^+.*@Ignore'          0

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 (upload Příliš žluťoučký kůň "test".txt and check the header on all three endpoints)
happens after merge and deploy on dev-6:8603.

Checklist

  • CI green
  • Tests added and green on all three endpoints
  • Deviations from the card's predictions documented above
  • Checkstyle clean

Source: a3627a6817 (dtq-dev PR #1368) · card BE-01.

🤖 Generated with Claude Code

…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>
@milanmajchrak
milanmajchrak merged commit 17ef6e1 into dtq-dev-9-base Sep 9, 2026
12 checks passed
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.

1 participant