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.js CHANGED
@@ -8146,7 +8146,14 @@
8146
8146
  value: function slice() {
8147
8147
  var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
8148
8148
  var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
8149
- if (start === end) {
8149
+ // Clamp to the data actually held, the way ArrayBuffer.prototype.slice
8150
+ // does. Otherwise a value length declared by a malformed file
8151
+ // allocates the declared size however few bytes are really present.
8152
+ // https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
8153
+ if (end > this.byteLength) {
8154
+ end = this.byteLength;
8155
+ }
8156
+ if (end <= start) {
8150
8157
  return new Uint8Array(0).buffer;
8151
8158
  }
8152
8159
  var index = this.findStart(start);
@@ -9690,8 +9697,8 @@
9690
9697
  }
9691
9698
  var DicomMessage$3, Tag$1, DicomMetaDictionary$1;
9692
9699
  var binaryVRs = ["FL", "FD", "SL", "SS", "UL", "US", "AT", "UV"],
9693
- length32VRs = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN", "OD", "UV"],
9694
- singleVRs$1 = ["SQ", "OF", "OW", "OB", "UN"];
9700
+ length32VRs = ["OB", "OW", "OF", "OL", "SQ", "UC", "UR", "UT", "UN", "OD", "UV"],
9701
+ singleVRs$1 = ["SQ", "OF", "OL", "OW", "OB", "UN"];
9695
9702
  var ValueRepresentation = /*#__PURE__*/function () {
9696
9703
  function ValueRepresentation(type) {
9697
9704
  _classCallCheck(this, ValueRepresentation);
@@ -10230,6 +10237,15 @@
10230
10237
  } else if (this.type == 'OB') {
10231
10238
  bytes = stream.readUint8Array(length);
10232
10239
  }*/
10240
+ // A declared value length longer than the data present means a
10241
+ // truncated or malformed file, so read what is there rather than
10242
+ // allocating the declared length, which the file controls.
10243
+ // https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
10244
+ var available = stream.endOffset - stream.offset;
10245
+ if (length > available) {
10246
+ validationLog.warn("".concat(this.type, " value declares ").concat(length, " bytes but only ").concat(available, " are available - reading the available bytes"));
10247
+ length = available;
10248
+ }
10233
10249
  bytes = stream.getBuffer(stream.offset, stream.offset + length);
10234
10250
  stream.increment(length);
10235
10251
  return [bytes];
@@ -11262,6 +11278,22 @@
11262
11278
  }
11263
11279
  _inherits(OtherFloatString, _BinaryRepresentation6);
11264
11280
  return _createClass(OtherFloatString);
11281
+ }(BinaryRepresentation); // A stream of 32 bit words. Used by the large mesh attributes of Surface
11282
+ // Segmentation - Long Triangle Point Index List (0066,0041) and its Edge and
11283
+ // Vertex counterparts - where the 16 bit indices of the OW forms cap a surface
11284
+ // at 65535 points.
11285
+ var OtherLongString = /*#__PURE__*/function (_BinaryRepresentation7) {
11286
+ function OtherLongString() {
11287
+ var _this34;
11288
+ _classCallCheck(this, OtherLongString);
11289
+ _this34 = _callSuper(this, OtherLongString, ["OL"]);
11290
+ _this34.maxLength = null;
11291
+ _this34.padByte = PADDING_NULL;
11292
+ _this34.noMultiple = true;
11293
+ return _this34;
11294
+ }
11295
+ _inherits(OtherLongString, _BinaryRepresentation7);
11296
+ return _createClass(OtherLongString);
11265
11297
  }(BinaryRepresentation); // these VR instances are precreate and are reused for each requested vr/tag
11266
11298
  var VRinstances = {
11267
11299
  AE: new ApplicationEntity(),
@@ -11279,6 +11311,7 @@
11279
11311
  OB: new OtherByteString(),
11280
11312
  OD: new OtherDoubleString(),
11281
11313
  OF: new OtherFloatString(),
11314
+ OL: new OtherLongString(),
11282
11315
  OW: new OtherWordString(),
11283
11316
  PN: new PersonName(),
11284
11317
  SH: new ShortString(),
@@ -12404,6 +12437,12 @@
12404
12437
  }
12405
12438
  }
12406
12439
  var _vr = ValueRepresentation.createByTypeString(dataItem.vr);
12440
+ if (dataItem.vr === "DS" && Array.isArray(dataItem.Value)) {
12441
+ // Format numbers to fit 16 characters instead of truncating String(number) below
12442
+ dataItem.Value = dataItem.Value.map(function (value) {
12443
+ return typeof value === "number" ? _vr.convertToString(value) : value;
12444
+ });
12445
+ }
12407
12446
  dataItem.Value = DicomMetaDictionary.denaturalizeValue(dataItem.Value);
12408
12447
  if (entry.vr == "SQ") {
12409
12448
  var unnaturalValues = [];