From 78665a43ba9c5835bd304f2065c17c3d7270b0cd Mon Sep 17 00:00:00 2001 From: Nick Gerner Date: Sat, 5 Dec 2020 08:56:40 -0800 Subject: Unclosed script/style tag handling Fixes #1614 (#1615) 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 = "