@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.cjs CHANGED
@@ -2134,8 +2134,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
2134
2134
  "UT",
2135
2135
  "UV"
2136
2136
  ]);
2137
+ function decodeXmlEntities(value) {
2138
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
2139
+ }
2140
+ function decodeIfString(value) {
2141
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
2142
+ }
2137
2143
  function buildPnString(comp) {
2138
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
2144
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
2139
2145
  let last = parts.length - 1;
2140
2146
  for (; last >= 0; last--) {
2141
2147
  if (parts[last] !== "") break;
@@ -2174,9 +2180,9 @@ function convertBulkDataURI(attr, element) {
2174
2180
  const bulkArray = toArray(attr.BulkDataURI);
2175
2181
  const firstBulk = bulkArray[0];
2176
2182
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
2177
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
2183
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
2178
2184
  } else {
2179
- element.BulkDataURI = safeString(firstBulk);
2185
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
2180
2186
  }
2181
2187
  }
2182
2188
  function convertPNValue(attr, element) {
@@ -2220,7 +2226,7 @@ function convertRegularValue(attr, element, vr) {
2220
2226
  const values = [];
2221
2227
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
2222
2228
  for (const v of valArray) {
2223
- const unwrapped = unwrapValue(v);
2229
+ const unwrapped = decodeIfString(unwrapValue(v));
2224
2230
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
2225
2231
  }
2226
2232
  if (values.length > 0) element.Value = values;