@ubercode/dcmtk 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -31290,8 +31290,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
31290
31290
  "UT",
31291
31291
  "UV"
31292
31292
  ]);
31293
+ function decodeXmlEntities(value) {
31294
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
31295
+ }
31296
+ function decodeIfString(value) {
31297
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
31298
+ }
31293
31299
  function buildPnString(comp) {
31294
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
31300
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
31295
31301
  let last = parts.length - 1;
31296
31302
  for (; last >= 0; last--) {
31297
31303
  if (parts[last] !== "") break;
@@ -31330,9 +31336,9 @@ function convertBulkDataURI(attr, element) {
31330
31336
  const bulkArray = toArray(attr.BulkDataURI);
31331
31337
  const firstBulk = bulkArray[0];
31332
31338
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
31333
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
31339
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
31334
31340
  } else {
31335
- element.BulkDataURI = safeString(firstBulk);
31341
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
31336
31342
  }
31337
31343
  }
31338
31344
  function convertPNValue(attr, element) {
@@ -31376,7 +31382,7 @@ function convertRegularValue(attr, element, vr) {
31376
31382
  const values = [];
31377
31383
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
31378
31384
  for (const v of valArray) {
31379
- const unwrapped = unwrapValue(v);
31385
+ const unwrapped = decodeIfString(unwrapValue(v));
31380
31386
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
31381
31387
  }
31382
31388
  if (values.length > 0) element.Value = values;