Skip to content

Commit

Permalink
Treat unknown vr as UN, fixes #1505
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Sep 22, 2023
1 parent 4dc492c commit 51e4326
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/dicom/dicomParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,18 @@ export function getDataElementPrefixByteSize(vr, isImplicit) {
return isImplicit ? 8 : is32bitVLVR(vr) ? 12 : 8;
}

/**
* Is the input VR a known VR.
*
* @param {string} vr The vr to test.
* @returns {boolean} True if known.
*/
function isKnownVR(vr) {
const extraVrTypes = ['NONE', 'ox', 'xx', 'xs'];
const knownTypes = Object.keys(vrTypes).concat(extraVrTypes);
return knownTypes.includes(vr);
}

/**
* DicomParser class.
*
Expand Down Expand Up @@ -799,6 +811,13 @@ export class DicomParser {
is32bitVL = true;
}

// check vr
if (!isKnownVR(vr)) {
logger.warn('Unknown VR: ' + vr +
' (for tag ' + tag.getKey() + '), treating as \'UN\'');
vr = 'UN';
}

// Value Length (VL)
let vl = 0;
if (is32bitVL) {
Expand Down

0 comments on commit 51e4326

Please sign in to comment.