Enforce String length when writing dicom file #96
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.
At present, "String" lengths are not enforced before writing tags. This can lead to overflows and invalid DICOM.
For example:
(0x0010, 0x1020) -> 1.2345678910111213(Patient Size - VR: DS) gets written as is and breaks the rest of the DICOM file.This PR attempts to fix this in most cases by enforcing the maximum length when writing string values.
The DICOM standard makes the distinction between char and bytes for different VR. When specifying maximum bytes, however, the chartset (ascii subset) matches with the number of chars, so we can collect the
firstchars in both cases.PNneeds special care as the limit is enforced bycomponent.I double-checked the maximum lengths by VR but it might be worth someone else checking again.