@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/dicom.js CHANGED
@@ -30608,8 +30608,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
30608
30608
  "UT",
30609
30609
  "UV"
30610
30610
  ]);
30611
+ function decodeXmlEntities(value) {
30612
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
30613
+ }
30614
+ function decodeIfString(value) {
30615
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
30616
+ }
30611
30617
  function buildPnString(comp) {
30612
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
30618
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
30613
30619
  let last = parts.length - 1;
30614
30620
  for (; last >= 0; last--) {
30615
30621
  if (parts[last] !== "") break;
@@ -30648,9 +30654,9 @@ function convertBulkDataURI(attr, element) {
30648
30654
  const bulkArray = toArray(attr.BulkDataURI);
30649
30655
  const firstBulk = bulkArray[0];
30650
30656
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
30651
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
30657
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
30652
30658
  } else {
30653
- element.BulkDataURI = safeString(firstBulk);
30659
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
30654
30660
  }
30655
30661
  }
30656
30662
  function convertPNValue(attr, element) {
@@ -30694,7 +30700,7 @@ function convertRegularValue(attr, element, vr) {
30694
30700
  const values = [];
30695
30701
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
30696
30702
  for (const v of valArray) {
30697
- const unwrapped = unwrapValue(v);
30703
+ const unwrapped = decodeIfString(unwrapValue(v));
30698
30704
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
30699
30705
  }
30700
30706
  if (values.length > 0) element.Value = values;