@poe-platform/safe-bash 0.1.758 → 0.1.759

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.
Files changed (26) hide show
  1. package/dist/image-ast/index.browser.js +15 -5
  2. package/dist/image-ast/index.js +15 -5
  3. package/dist/pdf-ast/index.js +15 -5
  4. package/dist/safe-bash/chunks/{chunk-WNWIBBJZ.js → chunk-AYPUGSOV.js} +7 -1
  5. package/dist/safe-bash/command-chunks/{chunk-XYCWDGOG.js → chunk-7JA44PVV.js} +1 -1
  6. package/dist/safe-bash/command-chunks/{chunk-TCAGGM44.js → chunk-BAUGDXLZ.js} +15 -6
  7. package/dist/safe-bash/command-chunks/{chunk-L2C5TIII.js → chunk-HVEAK3OS.js} +2 -2
  8. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  9. package/dist/safe-bash/commands/python/shell-capability.js +10 -2
  10. package/dist/safe-bash/core.browser.js +1 -1
  11. package/dist/safe-bash-command-ffmpeg/index.js +618 -613
  12. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  13. package/dist/safe-bash-command-pandoc/command.js +3 -3
  14. package/dist/safe-bash-command-pandoc/index.js +3 -3
  15. package/dist/safe-bash-command-pdfimages/index.js +15 -5
  16. package/dist/safe-bash-command-pdfinfo/index.js +15 -5
  17. package/dist/safe-bash-command-pdftk/index.js +15 -5
  18. package/dist/safe-bash-command-pdftoppm/index.js +15 -5
  19. package/dist/safe-bash-command-pdftotext/index.js +15 -5
  20. package/dist/safe-bash-command-qpdf/index.js +15 -5
  21. package/dist/safe-bash-command-sips/index.js +2 -2
  22. package/dist/safe-bash-command-soffice/index.js +1 -1
  23. package/dist/safe-bash-command-ssconvert/index.js +37 -27
  24. package/dist/safe-bash-command-wkhtmltopdf/index.js +16 -5
  25. package/package.json +2 -2
  26. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +14 -0
@@ -2604,22 +2604,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
2604
2604
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
2605
2605
  } catch (error) {
2606
2606
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
2607
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
2607
2608
  const decoder2 = new Inflate({
2608
- raw: !(bytes[0] === 31 && bytes[1] === 139),
2609
+ raw: !wrapped,
2609
2610
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
2610
2611
  });
2612
+ const chunks = [];
2611
2613
  let length2 = 0;
2612
2614
  decoder2.onData = (chunk) => {
2613
2615
  length2 += chunk.length;
2614
2616
  if (length2 > maxDecodedBytes) {
2615
2617
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
2616
2618
  }
2617
- decoder2.chunks.push(chunk);
2619
+ chunks.push(chunk);
2618
2620
  };
2619
- if (!decoder2.push(bytes, true) || decoder2.err || !decoder2.ended) {
2621
+ const complete = decoder2.push(bytes, true);
2622
+ const truncated = wrapped && decoder2.err === Z_BUF_ERROR && length2 > 0;
2623
+ if ((!complete || decoder2.err || !decoder2.ended) && !truncated) {
2620
2624
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
2621
2625
  }
2622
- inflated = decoder2.result;
2626
+ inflated = new Uint8Array(length2);
2627
+ let offset = 0;
2628
+ for (const chunk of chunks) {
2629
+ inflated.set(chunk, offset);
2630
+ offset += chunk.length;
2631
+ }
2623
2632
  }
2624
2633
  return applyPredictor(inflated, parms);
2625
2634
  }
@@ -10490,7 +10499,7 @@ function resolvePageFonts(doc, resourcesDict) {
10490
10499
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
10491
10500
  const widths = /* @__PURE__ */ new Map();
10492
10501
  let defaultWidth = 556;
10493
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
10502
+ const isTwoByteCid = subtype === "Type0";
10494
10503
  let fontMatrix;
10495
10504
  let charProcs;
10496
10505
  let fontResources;
@@ -14927,6 +14936,7 @@ var makeTable;
14927
14936
  var crcTable;
14928
14937
  var crc32;
14929
14938
  var messages_default;
14939
+ var Z_BUF_ERROR;
14930
14940
  var MAX_MEM_LEVEL;
14931
14941
  var HEAP_SIZE;
14932
14942
  var MIN_MATCH;
@@ -15929,6 +15939,7 @@ var init_dist = __esm({
15929
15939
  "-5": "buffer error",
15930
15940
  "-6": "incompatible version"
15931
15941
  };
15942
+ Z_BUF_ERROR = -5;
15932
15943
  MAX_MEM_LEVEL = 9;
15933
15944
  HEAP_SIZE = 573;
15934
15945
  MIN_MATCH = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.758",
3
+ "version": "0.1.759",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -841,7 +841,7 @@
841
841
  "access": "public"
842
842
  },
843
843
  "dependencies": {
844
- "@poe-platform/safe-fs": "0.1.758",
844
+ "@poe-platform/safe-fs": "0.1.759",
845
845
  "pdf-lib": "1.17.1",
846
846
  "@noble/hashes": "2.4.0",
847
847
  "pako": "3.0.1",
@@ -179,6 +179,12 @@ Word-spacing classification follows PDF.js `Font.charsToGlyphs`
179
179
  receives Tw, regardless of its Unicode label. The internal CMap reader preserves
180
180
  that classification without changing the public ToUnicode result shape.
181
181
 
182
+ Simple-font character segmentation also follows `Font.charsToGlyphs`: Type1,
183
+ TrueType, and Type3 strings use single-byte codes even when ToUnicode declares
184
+ a wider codespace. `src/fonts/simple-font-codespace.test.ts` checks that behavior
185
+ and the original upstream issue17069 equality fixture, including TJ fragments,
186
+ word spacing, Unicode labels spanning multiple characters, and save/reopen.
187
+
182
188
 
183
189
  # SVG labels
184
190
 
@@ -223,6 +229,14 @@ additional regressions use the extracted upstream streams listed in
223
229
  1996–2003 Glyph & Cog, LLC, Apache-2.0. The upstream Flate implementation is a
224
230
  JavaScript port of XPDF's implementation.
225
231
 
232
+ `src/cos/pypdf-flate-recovery.test.ts` adapts the printable-byte example from
233
+ pypdf 6.19.0 `tests/test_filters.py::test_decompress`, with truncation results
234
+ checked against `pypdf.filters.decompress`. The bounded pako fallback in
235
+ `src/cos/filters.ts` retains partial zlib/gzip output on incomplete input,
236
+ following pypdf's recovery behavior without its byte-at-a-time decoding loop.
237
+ The original PDF.js issue11549 fixture additionally checks the recovered
238
+ Unicode map against pypdf's decoded bytes. pypdf attribution/license is below.
239
+
226
240
  # PDF standard security handler
227
241
 
228
242
  `src/vendor/pdfjs-fonts.mjs` also includes `src/core/crypto.js`,