Przeglądaj źródła

Infinite loop fix on incomplete uls

main
Rocketsoup 1 rok temu
rodzic
commit
a1169ad47b
2 zmienionych plików z 12 dodań i 1 usunięć
  1. 1
    1
      js/markdown.js
  2. 11
    0
      testjs.html

+ 1
- 1
js/markdown.js Wyświetl plik

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

+ 11
- 0
testjs.html Wyświetl plik

905
 					this.assertEqual(actual, expected);
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
 				test_orderedList() {
919
 				test_orderedList() {
909
 					let markdown = "1. Lorem\n1. Ipsum\n5. Dolor";
920
 					let markdown = "1. Lorem\n1. Ipsum\n5. Dolor";
910
 					let expected = '<ol> <li>Lorem</li> <li>Ipsum</li> <li>Dolor</li> </ol>';
921
 					let expected = '<ol> <li>Lorem</li> <li>Ipsum</li> <li>Dolor</li> </ol>';

Ładowanie…
Anuluj
Zapisz