Skip to content

Conversation

PaulHax
Copy link
Collaborator

@PaulHax PaulHax commented Oct 9, 2025

We are seeing DICOM date tags in the wild that have control characters in some of their date VR tags. See attached DICOM file in the zip
corrupt_dates.zip

When loading this file in VolView we got an error calling @itk-wasm/image-io::readImage:

Error loading DICOM data SyntaxError: Bad control character in string literal in JSON at position 1786 (line 109 column 16)
    at JSON.parse (<anonymous>)
    at getPipelineModuleOutputJSON (http://localhost:5174/node_modules/itk-wasm/dist/pipeline/internal/run-pipeline-emscripten.js:62:29)

Now we are escaping these control characters via a patch.

In the future could fix @itk-wasm/image-io::readImage's use of the glaze JSON library to use its escape_control_characters option.

Copy link

netlify bot commented Oct 9, 2025

Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit 859dadc
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/68e71ec4f3bff0000800ea06
😎 Deploy Preview https://deploy-preview-799--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Patch itk-wasm to escape control characters (ASCII 0-31 except tab/LF/CR,
plus DEL) in JSON strings before parsing. This fixes avoids this error
`SyntaxError: Bad control character in string literal in JSON`

The readImage GDCM reader reads these corrupt tags literally and serializes them to
JSON without escaping, causing JSON.parse() to error.
@PaulHax PaulHax force-pushed the dicom-bad-date-tags branch from b8756ac to 859dadc Compare October 9, 2025 02:32
@PaulHax PaulHax requested a review from zachmullen October 9, 2025 15:53
@zachmullen
Copy link
Member

Can we just upstream this fix to the relevant itk-wasm libraries (given that we control them) and bump our dependency version? That seems preferable to patching, in terms of maintainability.

@PaulHax
Copy link
Collaborator Author

PaulHax commented Oct 9, 2025

Agreed. Starting that InsightSoftwareConsortium/ITK-Wasm#1454

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