From 4b2326fdef15e58954a14b79def6099cbd1a880e Mon Sep 17 00:00:00 2001 From: Nick Gerner Date: Fri, 27 Nov 2020 11:09:43 -0800 Subject: [PATCH] Unclosed script/style tag handling Fixes #1614 Explicitly handle unclosed " + start_time = time.time() + tokens = list(lexer_html.get_tokens(fragment)) + assert all(x[1] != Token.Error for x in tokens) + assert time.time() - start_time < 1, 'The HTML lexer might have an expensive happy-path script case' + +def test_happy_css_fragment(lexer_html): + """ valid, even long CSS fragments should still get parsed ok """ + + fragment = "" + start_time = time.time() + tokens = list(lexer_html.get_tokens(fragment)) + assert all(x[1] != Token.Error for x in tokens) + assert time.time() - start_time < 1, 'The HTML lexer might have an expensive happy-path style case' + +def test_long_unclosed_javascript_fragment(lexer_html): + """ unclosed, long Javascript fragments should parse quickly """ + + reps = 2000 + fragment = "