@patrickdk77/pdf-defuse 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/objects.js +1 -6
  2. package/package.json +1 -1
package/dist/objects.js CHANGED
@@ -169,10 +169,5 @@ function encodeTextString(text) {
169
169
  // biome-ignore lint/suspicious/noControlCharactersInRegex: the range PDFDocEncoding keeps as is starts with control codes.
170
170
  if (/^[\x00-\x17\x20-\x7e]*$/.test(text))
171
171
  return Buffer.from(text, 'latin1');
172
- const out = Buffer.alloc(2 + text.length * 2);
173
- out[0] = 0xfe;
174
- out[1] = 0xff;
175
- for (let i = 0; i < text.length; i++)
176
- out.writeUInt16BE(text.charCodeAt(i), 2 + i * 2);
177
- return out;
172
+ return Buffer.concat([Buffer.from([0xfe, 0xff]), Buffer.from(text, 'utf16le').swap16()]);
178
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patrickdk77/pdf-defuse",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Sanitize and clean PDF files. Detects and removes JavaScript, attached files, launch actions, unsafe links and empty-password encryption, scores the risk, and writes a disarmed copy with bounded memory and no runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "patrickdk77",