fix: strip XML prolog from the text/html fallback body
This commit is contained in:
parent
3d9239b7a5
commit
12956a5034
3 changed files with 40 additions and 2 deletions
|
|
@ -115,6 +115,26 @@ class TestWmlCardUrls:
|
|||
assert b"{.card" not in doc.xhtml
|
||||
|
||||
|
||||
class TestHtmlFallbackHasNoXmlProlog:
|
||||
def test_html_field_has_no_prolog(self, site: Site):
|
||||
# A browser parsing this as text/html (rather than XML) tolerates
|
||||
# a leading <?xml ...?> as a bogus comment and still renders the
|
||||
# page, but logs a console warning -- so the text/html fallback
|
||||
# must not carry it.
|
||||
doc = site.resolve("/")
|
||||
assert not doc.html.startswith(b"<?xml")
|
||||
assert doc.html.startswith(b"<!DOCTYPE html")
|
||||
|
||||
def test_xhtml_field_keeps_the_prolog(self, site: Site):
|
||||
# Real XHTML-MP/WAP 2.0 clients still need well-formed XML.
|
||||
doc = site.resolve("/")
|
||||
assert doc.xhtml.startswith(b'<?xml version="1.0"')
|
||||
|
||||
def test_html_and_xhtml_are_otherwise_identical(self, site: Site):
|
||||
doc = site.resolve("/")
|
||||
assert doc.html == doc.xhtml[doc.xhtml.index(b"<!DOCTYPE"):]
|
||||
|
||||
|
||||
class TestLiveReload:
|
||||
def test_edited_file_is_rerendered(self, tmp_path: Path):
|
||||
target = tmp_path / "index.md"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue