dcmjs 0.52.1 → 0.52.3

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/build/dcmjs.es.js CHANGED
@@ -8140,7 +8140,14 @@ var SplitDataView = /*#__PURE__*/function () {
8140
8140
  value: function slice() {
8141
8141
  var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
8142
8142
  var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
8143
- if (start === end) {
8143
+ // Clamp to the data actually held, the way ArrayBuffer.prototype.slice
8144
+ // does. Otherwise a value length declared by a malformed file
8145
+ // allocates the declared size however few bytes are really present.
8146
+ // https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
8147
+ if (end > this.byteLength) {
8148
+ end = this.byteLength;
8149
+ }
8150
+ if (end <= start) {
8144
8151
  return new Uint8Array(0).buffer;
8145
8152
  }
8146
8153
  var index = this.findStart(start);
@@ -9684,8 +9691,8 @@ function toWindows(inputArray, size) {
9684
9691
  }
9685
9692
  var DicomMessage$3, Tag$1, DicomMetaDictionary$1;
9686
9693
  var binaryVRs = ["FL", "FD", "SL", "SS", "UL", "US", "AT", "UV"],
9687
- length32VRs = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN", "OD", "UV"],
9688
- singleVRs$1 = ["SQ", "OF", "OW", "OB", "UN"];
9694
+ length32VRs = ["OB", "OW", "OF", "OL", "SQ", "UC", "UR", "UT", "UN", "OD", "UV"],
9695
+ singleVRs$1 = ["SQ", "OF", "OL", "OW", "OB", "UN"];
9689
9696
  var ValueRepresentation = /*#__PURE__*/function () {
9690
9697
  function ValueRepresentation(type) {
9691
9698
  _classCallCheck(this, ValueRepresentation);
@@ -10224,6 +10231,15 @@ var BinaryRepresentation = /*#__PURE__*/function (_ValueRepresentation3) {
10224
10231
  } else if (this.type == 'OB') {
10225
10232
  bytes = stream.readUint8Array(length);
10226
10233
  }*/
10234
+ // A declared value length longer than the data present means a
10235
+ // truncated or malformed file, so read what is there rather than
10236
+ // allocating the declared length, which the file controls.
10237
+ // https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
10238
+ var available = stream.endOffset - stream.offset;
10239
+ if (length > available) {
10240
+ validationLog.warn("".concat(this.type, " value declares ").concat(length, " bytes but only ").concat(available, " are available - reading the available bytes"));
10241
+ length = available;
10242
+ }
10227
10243
  bytes = stream.getBuffer(stream.offset, stream.offset + length);
10228
10244
  stream.increment(length);
10229
10245
  return [bytes];
@@ -11256,6 +11272,22 @@ var OtherFloatString = /*#__PURE__*/function (_BinaryRepresentation6) {
11256
11272
  }
11257
11273
  _inherits(OtherFloatString, _BinaryRepresentation6);
11258
11274
  return _createClass(OtherFloatString);
11275
+ }(BinaryRepresentation); // A stream of 32 bit words. Used by the large mesh attributes of Surface
11276
+ // Segmentation - Long Triangle Point Index List (0066,0041) and its Edge and
11277
+ // Vertex counterparts - where the 16 bit indices of the OW forms cap a surface
11278
+ // at 65535 points.
11279
+ var OtherLongString = /*#__PURE__*/function (_BinaryRepresentation7) {
11280
+ function OtherLongString() {
11281
+ var _this34;
11282
+ _classCallCheck(this, OtherLongString);
11283
+ _this34 = _callSuper(this, OtherLongString, ["OL"]);
11284
+ _this34.maxLength = null;
11285
+ _this34.padByte = PADDING_NULL;
11286
+ _this34.noMultiple = true;
11287
+ return _this34;
11288
+ }
11289
+ _inherits(OtherLongString, _BinaryRepresentation7);
11290
+ return _createClass(OtherLongString);
11259
11291
  }(BinaryRepresentation); // these VR instances are precreate and are reused for each requested vr/tag
11260
11292
  var VRinstances = {
11261
11293
  AE: new ApplicationEntity(),
@@ -11273,6 +11305,7 @@ var VRinstances = {
11273
11305
  OB: new OtherByteString(),
11274
11306
  OD: new OtherDoubleString(),
11275
11307
  OF: new OtherFloatString(),
11308
+ OL: new OtherLongString(),
11276
11309
  OW: new OtherWordString(),
11277
11310
  PN: new PersonName(),
11278
11311
  SH: new ShortString(),
@@ -12398,6 +12431,12 @@ var DicomMetaDictionary = /*#__PURE__*/function () {
12398
12431
  }
12399
12432
  }
12400
12433
  var _vr = ValueRepresentation.createByTypeString(dataItem.vr);
12434
+ if (dataItem.vr === "DS" && Array.isArray(dataItem.Value)) {
12435
+ // Format numbers to fit 16 characters instead of truncating String(number) below
12436
+ dataItem.Value = dataItem.Value.map(function (value) {
12437
+ return typeof value === "number" ? _vr.convertToString(value) : value;
12438
+ });
12439
+ }
12401
12440
  dataItem.Value = DicomMetaDictionary.denaturalizeValue(dataItem.Value);
12402
12441
  if (entry.vr == "SQ") {
12403
12442
  var unnaturalValues = [];