Bläddra i källkod

Remove unnecessary "match anything" test that caused excessive run time on some mixed content
Update HTML5 structural tags test to also verify correctness this regexp and the previous one.

Signed-off-by: unwiredben <combee@techwood.org>

unwiredben 13 år sedan
förälder
incheckning
9b297fa877
3 ändrade filer med 12 tillägg och 6 borttagningar
  1. 2 2
      src/showdown.js
  2. 5 2
      test/cases/html5-strutural-tags.html
  3. 5 2
      test/cases/html5-strutural-tags.md

+ 2 - 2
src/showdown.js

@@ -259,13 +259,13 @@ var _HashHTMLBlocks = function(text) {
 			\b					// word break
 								// attacklab: hack around khtml/pcre bug...
 			[^\r]*?				// any number of lines, minimally matching
-			.*</\2>				// the matching end tag
+			</\2>				// the matching end tag
 			[ \t]*				// trailing spaces/tabs
 			(?=\n+)				// followed by a newline
 		)						// attacklab: there are sentinel newlines at end of document
 		/gm,function(){...}};
 	*/
-	text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
+	text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
 
 	// Special case just for <hr />. It was easier to make a special case than
 	// to make the other regex more complicated.

+ 5 - 2
test/cases/html5-strutural-tags.html

@@ -9,8 +9,11 @@
 
 <nav>navigation</nav>
 
-<article>read me</article>
+<article>read
+me</article>
 
-<aside>ignore me</aside>
+<aside>
+ignore me
+</aside>
 
 <p>the end</p>

+ 5 - 2
test/cases/html5-strutural-tags.md

@@ -5,7 +5,10 @@ These HTML5 tags should pass through just fine.
 <header>head</header>
 <footer>footsies</footer>
 <nav>navigation</nav>
-<article>read me</article>
-<aside>ignore me</aside>
+<article>read
+me</article>
+<aside>
+ignore me
+</aside>
 
 the end