Skip to content

fix(dicom-pdf): guarantee the type of encapsulated documents and release 3.12.15 (#6228) - #6258

Merged
jbocce merged 2 commits into
OHIF:release/3.12from
jbocce:fix/pdf-release-3.12
Sep 8, 2026
Merged

fix(dicom-pdf): guarantee the type of encapsulated documents and release 3.12.15 (#6228)#6258
jbocce merged 2 commits into
OHIF:release/3.12from
jbocce:fix/pdf-release-3.12

Conversation

@jbocce

@jbocce jbocce commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

More or less a cherry-pick of #6228 with edits to version.txt for the release and postcss.config.js to turn off the prefixer which was giving warnings since the list of supported browsers no longer needs prefixes.

* fix(dicom-pdf): guarantee the type of encapsulated documents

MIMETypeOfEncapsulatedDocument is supplied by whoever produced the
instance, and a blob: URL inherits the origin of the document that
created it, so a spoofed text/html payload executed same-origin with
the viewer and could read its localStorage. The `type` attribute on
<object> is only a hint - the browser keys off the resource's actual
Content-Type - so it never filtered anything.

Documents are now always read into memory and re-wrapped in a Blob
whose type comes from an allowlist, so neither the instance nor the
origin server's Content-Type can steer how the browser interprets the
bytes. PDF payloads additionally have to satisfy a %PDF- signature
check. This also closes the case where a raw WADO-RS URL reached the
element directly and the PACS chose the Content-Type.

The allowlist maps each canonical type to how it is embedded:

  application/pdf              -> <object type="application/pdf">
  text/html, xhtml, xml, plain -> <iframe sandbox="">
  anything else                -> not rendered

The split is forced by the browsers rather than chosen: Chrome renders
a PDF under no sandbox at all and under none of the token combinations,
including the fully permissive `allow-scripts allow-same-origin`, so
PDFs cannot be sandboxed and rely on the type guarantee instead. Markup
types render correctly inside a sandbox, so they get one with no tokens.

Non-standard spellings (application/html, application/x-pdf,
application/acrobat, text/pdf, application/xhtml) fold onto their
canonical entry, which is safe because the canonical entry - not the
declared spelling - decides both the Blob type and the signature.

This extension had neither a jest nor a babel config, so the root
extensions/*/jest.config.js project glob never collected its tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor(dicom-pdf): load documents through the data source

The previous commit reached the payload with its own fetch(), which
bypassed the data source and needed CORS on a cross-origin WADO URL.

Documents are now read the way every other bulkdata value is read:
inline content when the metadata carries it, otherwise the data
source's own retrieveBulkData, preferring the buffer it caches on
value.Value. This mirrors resolveBulkDataTags and matches the path the
video display sets take, so authentication, bulkdata URI resolution
and caching all behave the same here.

The type guarantee is unchanged - the bytes are still wrapped in a
Blob whose type comes from the allowlist, and PDF payloads still have
to satisfy the %PDF- signature check - but it no longer depends on
re-fetching a URL whose Content-Type was never trustworthy.

The SOP class handler now hands the display set a getDocument loader
instead of renderedUrl/getRenderedUrl. Those were consumed only by
this viewport, and directURL eagerly created an object URL per DOC
instance at metadata time that nothing revoked.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dicom-pdf): move document viewport strings into i18n

The viewport's status and fallback strings were hardcoded English. They
now come from a new EncapsulatedDocument namespace via useTranslation,
registered in both the en-US and test-LNG locale indexes.

react-i18next is declared as a peer dependency, matching how the other
extensions that use useTranslation declare it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(security): bump browserslist and fast-uri past new high advisories

The CircleCI security audit gate runs whenever pnpm-lock.yaml changes.
Newly published advisories put two build-time transitive deps over the
high threshold:

- browserslist <=4.28.6 (GHSA-c83g-rgw3-j3cx, GHSA-73wf-gq98-2v4g),
  reached via @babel/helper-compilation-targets. Override to 4.28.8.
- fast-uri <3.1.6 (GHSA-5jgf-p345-68v8, GHSA-f65p-4m7j-42xc,
  GHSA-fph4-wmhf-6fwf, GHSA-jqff-g426-hqxp), reached via
  babel-loader > webpack > schema-utils > ajv. Widen the existing
  override to 3.1.6.

fast-uri 3.1.7 exists but was published today and trips the repo's
2-day minimumReleaseAge gate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(dicom-pdf): accept a valid pdf whose header is not at byte 0

The signature check required %PDF- at offset 0, which rejects legitimate
documents that carry a UTF-8 BOM or other leading bytes before the header.
Adobe's implementation note allows the header anywhere in the first 1024
bytes and mainstream readers follow it, so scan that same bounded window.

The check still does its actual job: a payload declared as PDF that is
really markup carries no %PDF- anywhere and is still refused.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: bb02a0e7-38ce-40d1-bf10-90f86c65fe46

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jbocce
jbocce requested a review from wayfarer3130 September 7, 2026 18:55
The chore(version) release commits bump every package.json to the new
workspace version but never regenerate bun.lock, and bun's incremental
update only rewrote the 47 "version" fields plus a handful of dependency
maps when this branch ran an install. That left 110 @ohif/@externals
specifiers in bun.lock still pointing at 3.12.13 while the package.json
files they mirror all say 3.12.14.

Every mismatch was verified to be exactly 3.12.13 -> 3.12.14 against the
referring package.json, with no missing entries and no other divergence,
so all 110 are synced. bun install --frozen-lockfile now resolves without
rewriting the lockfile, and bun audit at the CI gate's level is unchanged
because no third-party resolution moved.

Also re-indents the isCancelled block in the PDF viewport, which was the
only substantive divergence from the same file as merged on master. Left
as-is, lint-staged prettier would rewrite it on the next commit touching
the file and make future cross-branch cherry-picks conflict for no reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jbocce
jbocce merged commit f0dba78 into OHIF:release/3.12 Sep 8, 2026
3 checks passed
@jbocce
jbocce deleted the fix/pdf-release-3.12 branch September 8, 2026 16:59
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.

2 participants