Skip to content

Commit

Permalink
Insert extra characters to avoid the character encoding scanner seein…
Browse files Browse the repository at this point in the history
…g the test markup
  • Loading branch information
zcorpan committed Sep 8, 2021
1 parent 1481185 commit c258849
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
/html/syntax/speculative-parsing/tools/generate.py
-->
<!-- no meta charset -->
<!-- (padding to exceed 1024 bytes processed by the character encoding scanner) -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<title>Speculative parsing, document.write(): meta-charset-script-src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
Expand All @@ -20,6 +30,6 @@
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<meta\ charset=windows-1254><script src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;"><\/script>
<meta charset=windows-1254><script src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;"><\/script>
`);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
/html/syntax/speculative-parsing/tools/generate.py
-->
<!-- no meta charset -->
<!-- (padding to exceed 1024 bytes processed by the character encoding scanner) -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<title>Speculative parsing, page load: meta-charset-script-src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
/html/syntax/speculative-parsing/tools/generate.py
-->
<!-- no meta charset -->
<!-- (padding to exceed 1024 bytes processed by the character encoding scanner) -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<title>Speculative parsing, page load (helper file): meta-charset-script-src</title>
<script src="/common/slow.py?delay=1500"></script>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
/html/syntax/speculative-parsing/tools/generate.py
-->
<!-- no meta charset -->
<!-- (padding to exceed 1024 bytes processed by the character encoding scanner) -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<title>Speculative parsing, non-speculative (helper file): meta-charset-script-src</title>
<!-- non-speculative case -->
<meta charset=windows-1254><script src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid={{GET[uuid]}}&amp;encodingcheck=&Gbreve;"></script>
Expand Down
16 changes: 14 additions & 2 deletions html/syntax/speculative-parsing/tools/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,18 @@
/html/syntax/speculative-parsing/tools/generate.py
-->"""

no_meta_charset = u"""<!-- no meta charset -->
<!-- (padding to exceed 1024 bytes processed by the character encoding scanner) -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->"""

# Notes on `encodingcheck` in the URL below
#
# - &Gbreve; is the HTML character reference for U+011E LATIN CAPITAL LETTER G WITH BREVE
Expand Down Expand Up @@ -545,12 +557,12 @@ def generate_tests(testcase, tentative):
ext = u".tentative"

if encoding is None:
encoding_decl = u"<!-- no meta charset -->"
encoding_decl = no_meta_charset
else:
encoding_decl = f"<meta charset={encoding}>"

html_testcase_markup = template_testcase_markup.format(url_wptserve_sub)
js_testcase_markup = template_testcase_markup.format(url_js_sub).replace(u"</script>", u"<\/script>").replace(u"<meta charset", u"<meta\ charset")
js_testcase_markup = template_testcase_markup.format(url_js_sub).replace(u"</script>", u"<\/script>")

if test_nonspeculative is u'true':
nonspeculative = template_nonspeculative.format(preamble=preamble, encoding_decl=encoding_decl, title=title, testcase_markup=html_testcase_markup, delay=delay)
Expand Down

0 comments on commit c258849

Please sign in to comment.