@ubercode/dcmtk 0.15.0 → 0.16.0

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/dicom.cjs CHANGED
@@ -30614,8 +30614,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
30614
30614
  "UT",
30615
30615
  "UV"
30616
30616
  ]);
30617
+ function decodeXmlEntities(value) {
30618
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
30619
+ }
30620
+ function decodeIfString(value) {
30621
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
30622
+ }
30617
30623
  function buildPnString(comp) {
30618
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
30624
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
30619
30625
  let last = parts.length - 1;
30620
30626
  for (; last >= 0; last--) {
30621
30627
  if (parts[last] !== "") break;
@@ -30654,9 +30660,9 @@ function convertBulkDataURI(attr, element) {
30654
30660
  const bulkArray = toArray(attr.BulkDataURI);
30655
30661
  const firstBulk = bulkArray[0];
30656
30662
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
30657
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
30663
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
30658
30664
  } else {
30659
- element.BulkDataURI = safeString(firstBulk);
30665
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
30660
30666
  }
30661
30667
  }
30662
30668
  function convertPNValue(attr, element) {
@@ -30700,7 +30706,7 @@ function convertRegularValue(attr, element, vr) {
30700
30706
  const values = [];
30701
30707
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
30702
30708
  for (const v of valArray) {
30703
- const unwrapped = unwrapValue(v);
30709
+ const unwrapped = decodeIfString(unwrapValue(v));
30704
30710
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
30705
30711
  }
30706
30712
  if (values.length > 0) element.Value = values;