Преглед изворни кода

Infinite loop fix on incomplete uls

main
Rocketsoup пре 1 година
родитељ
комит
a1169ad47b
2 измењених фајлова са 12 додато и 1 уклоњено
  1. 1
    1
      js/markdown.js
  2. 11
    0
      testjs.html

+ 1
- 1
js/markdown.js Прегледај датотеку

@@ -681,7 +681,7 @@ class MDBaseListBlockReader extends MDBlockReader {
681 681
 	 */
682 682
 	readListItemContent(state, firstLineStartPos) {
683 683
 		const itemLines = this.#readItemLines(state, firstLineStartPos);
684
-		state.p += itemLines.length;
684
+		state.p += Math.max(itemLines.length, 1);
685 685
 
686 686
 		if (itemLines.length == 1) {
687 687
 			return new MDInlineBlock(state.inlineMarkdownToSpans(itemLines[0]));

+ 11
- 0
testjs.html Прегледај датотеку

@@ -905,6 +905,17 @@
905 905
 					this.assertEqual(actual, expected);
906 906
 				}
907 907
 
908
+				test_unorderedList_hitch() {
909
+					// This incomplete bulleted list locked up the browser at one
910
+					// point, not forever but a REALLY long time
911
+					this.profile(1.0, () => {
912
+						let markdown = "Testing\n\n* ";
913
+						let expected = '<p>Testing</p> <ul> <li></li> </ul>';
914
+						let actual = this.md(markdown);
915
+						this.assertEqual(actual, expected);
916
+					});
917
+				}
918
+
908 919
 				test_orderedList() {
909 920
 					let markdown = "1. Lorem\n1. Ipsum\n5. Dolor";
910 921
 					let expected = '<ol> <li>Lorem</li> <li>Ipsum</li> <li>Dolor</li> </ol>';

Loading…
Откажи
Сачувај