@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/servers.js CHANGED
@@ -2109,8 +2109,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
2109
2109
  "UT",
2110
2110
  "UV"
2111
2111
  ]);
2112
+ function decodeXmlEntities(value) {
2113
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
2114
+ }
2115
+ function decodeIfString(value) {
2116
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
2117
+ }
2112
2118
  function buildPnString(comp) {
2113
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
2119
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
2114
2120
  let last = parts.length - 1;
2115
2121
  for (; last >= 0; last--) {
2116
2122
  if (parts[last] !== "") break;
@@ -2149,9 +2155,9 @@ function convertBulkDataURI(attr, element) {
2149
2155
  const bulkArray = toArray(attr.BulkDataURI);
2150
2156
  const firstBulk = bulkArray[0];
2151
2157
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
2152
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
2158
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
2153
2159
  } else {
2154
- element.BulkDataURI = safeString(firstBulk);
2160
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
2155
2161
  }
2156
2162
  }
2157
2163
  function convertPNValue(attr, element) {
@@ -2195,7 +2201,7 @@ function convertRegularValue(attr, element, vr) {
2195
2201
  const values = [];
2196
2202
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
2197
2203
  for (const v of valArray) {
2198
- const unwrapped = unwrapValue(v);
2204
+ const unwrapped = decodeIfString(unwrapValue(v));
2199
2205
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
2200
2206
  }
2201
2207
  if (values.length > 0) element.Value = values;