svelte-rtf-editor 1.8.0 → 1.8.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.
@@ -185,13 +185,16 @@ function tokenize(rtf) {
185
185
  if (i >= len)
186
186
  break;
187
187
  const next = rtf[i];
188
- // Hex escape \'xx
188
+ // Hex escape \'xx. One without two hex digits after it is damaged: it is dropped, and
189
+ // what follows it is read as usual, rather than turned into a NUL or a control character.
189
190
  if (next === "'") {
190
191
  i++;
191
192
  const hex = rtf.substring(i, i + 2);
192
- i += 2;
193
- const code = parseInt(hex, 16);
194
- tokens.push({ type: 'text', value: String.fromCharCode(WINDOWS_1252_C1[code - 0x80] ?? code) });
193
+ if (/^[0-9a-fA-F]{2}$/.test(hex)) {
194
+ i += 2;
195
+ const code = parseInt(hex, 16);
196
+ tokens.push({ type: 'text', value: String.fromCharCode(WINDOWS_1252_C1[code - 0x80] ?? code) });
197
+ }
195
198
  }
196
199
  // Special escapes
197
200
  else if (next === '\\' || next === '{' || next === '}') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-rtf-editor",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "RTF viewer and rich-text editor components for Svelte 5",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/jcelano/svelte-rtf-editor#readme",