@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.js CHANGED
@@ -31265,8 +31265,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
31265
31265
  "UT",
31266
31266
  "UV"
31267
31267
  ]);
31268
+ function decodeXmlEntities(value) {
31269
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
31270
+ }
31271
+ function decodeIfString(value) {
31272
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
31273
+ }
31268
31274
  function buildPnString(comp) {
31269
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
31275
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
31270
31276
  let last = parts.length - 1;
31271
31277
  for (; last >= 0; last--) {
31272
31278
  if (parts[last] !== "") break;
@@ -31305,9 +31311,9 @@ function convertBulkDataURI(attr, element) {
31305
31311
  const bulkArray = toArray(attr.BulkDataURI);
31306
31312
  const firstBulk = bulkArray[0];
31307
31313
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
31308
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
31314
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
31309
31315
  } else {
31310
- element.BulkDataURI = safeString(firstBulk);
31316
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
31311
31317
  }
31312
31318
  }
31313
31319
  function convertPNValue(attr, element) {
@@ -31351,7 +31357,7 @@ function convertRegularValue(attr, element, vr) {
31351
31357
  const values = [];
31352
31358
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
31353
31359
  for (const v of valArray) {
31354
- const unwrapped = unwrapValue(v);
31360
+ const unwrapped = decodeIfString(unwrapValue(v));
31355
31361
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
31356
31362
  }
31357
31363
  if (values.length > 0) element.Value = values;