@native-sdk/cli 0.8.0 → 0.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.
@@ -169,6 +169,16 @@ test "hostile: 100-deep quotes, lists, and details nesting stay bounded" {
169
169
  // Details nested past max_markdown_details_per_document, all expanded.
170
170
  for (0..40) |_| try stream.writeAll("<details>\n<summary>s</summary>\n\nbody\n\n");
171
171
  for (0..40) |_| try stream.writeAll("</details>\n");
172
+ // Safe HTML blockquotes recurse only to the mapper's bounded block
173
+ // depth, then consume the overflowing subtree without growing the tree.
174
+ for (0..100) |_| try stream.writeAll("<blockquote>\n");
175
+ try stream.writeAll("html quote body\n");
176
+ for (0..100) |_| try stream.writeAll("</blockquote>\n");
177
+ // Persistent block presentation has a bounded scope stack too; excess
178
+ // wrappers are ignored until their matching close drains the overflow.
179
+ for (0..100) |_| try stream.writeAll("<div align=\"center\">\n");
180
+ try stream.writeAll("centered body\n");
181
+ for (0..100) |_| try stream.writeAll("</div>\n");
172
182
 
173
183
  const result = try buildHostile(stream.buffered());
174
184
  try testing.expect(result.widgets > 0);
@@ -214,6 +224,18 @@ test "hostile: kilochar single words and megabyte paragraphs join in linear memo
214
224
  while (index < source.len) : (index += 41) source[index] = '\n';
215
225
  _ = try buildHostile(source);
216
226
  }
227
+
228
+ // Safe HTML block collection must consume the full element without
229
+ // retaining a source-sized copy in the view tree.
230
+ {
231
+ const source = try allocator.alloc(u8, 1024 * 1024);
232
+ defer allocator.free(source);
233
+ @memset(source, 'h');
234
+ @memcpy(source[0..3], "<p>");
235
+ @memcpy(source[source.len - 4 ..], "</p>");
236
+ const result = try buildHostile(source);
237
+ try testing.expect(result.text_bytes <= markdown.max_markdown_paragraph_bytes * 2);
238
+ }
217
239
  }
218
240
 
219
241
  test "hostile: bracket, autolink, and reference-link bombs parse in linear time" {
@@ -288,6 +310,24 @@ test "hostile: bare-url paren tails trim in linear time" {
288
310
  _ = try buildHostile(source);
289
311
  }
290
312
 
313
+ test "hostile: unterminated HTML comment-prefix walls parse in linear time" {
314
+ const allocator = testing.allocator;
315
+ const bomb_len = 256 * 1024;
316
+ const source = try allocator.alloc(u8, bomb_len);
317
+ defer allocator.free(source);
318
+
319
+ // Every four-byte prefix looks like a comment opener, but none has a
320
+ // closer. A fresh suffix scan at every '<' is quadratic; the HTML scan
321
+ // must remember the first unterminated comment through the remaining
322
+ // source and through the paragraph's measuring/copy passes.
323
+ var index: usize = 0;
324
+ while (index + 4 <= source.len) : (index += 4) @memcpy(source[index..][0..4], "<!--");
325
+ if (index < source.len) @memset(source[index..], '<');
326
+
327
+ const result = try buildHostile(source);
328
+ try testing.expect(result.text_bytes <= markdown.max_markdown_paragraph_bytes * 2);
329
+ }
330
+
291
331
  test "hostile: unterminated fences, HTML soup, and stray closers stay valid" {
292
332
  _ = try buildHostile(
293
333
  \\```zig