Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75cf697

Browse files
committed
Reintroduce the old sanitizer testsuite from html5lib-tests
This is imported into this repo as its expectations are very muchimplementation dependent, with expectations amended to match ouractual behaviour.
1 parenta2917e9 commit75cf697

File tree

4 files changed

+494
-5
lines changed

4 files changed

+494
-5
lines changed

‎html5lib/serializer/htmlserializer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ def serialize(self, treewalker, encoding=None):
184184
ifencodingandself.inject_meta_charset:
185185
from ..filters.inject_meta_charsetimportFilter
186186
treewalker=Filter(treewalker,encoding)
187+
# Alphabetical attributes is here under the assumption that none of
188+
# the later filters add or change order of attributes; it needs to be
189+
# before the sanitizer so escaped elements come out correctly
190+
ifself.alphabetical_attributes:
191+
from ..filters.alphabeticalattributesimportFilter
192+
treewalker=Filter(treewalker)
187193
# WhitespaceFilter should be used before OptionalTagFilter
188194
# for maximum efficiently of this latter filter
189195
ifself.strip_whitespace:
@@ -195,11 +201,6 @@ def serialize(self, treewalker, encoding=None):
195201
ifself.omit_optional_tags:
196202
from ..filters.optionaltagsimportFilter
197203
treewalker=Filter(treewalker)
198-
# Alphabetical attributes must be last, as other filters
199-
# could add attributes and alter the order
200-
ifself.alphabetical_attributes:
201-
from ..filters.alphabeticalattributesimportFilter
202-
treewalker=Filter(treewalker)
203204

204205
fortokenintreewalker:
205206
type=token["type"]

‎html5lib/tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
from .tree_constructionimportTreeConstructionFile
44
from .tokenizerimportTokenizerFile
5+
from .sanitizerimportSanitizerFile
56

67
_dir=os.path.abspath(os.path.dirname(__file__))
78
_testdata=os.path.join(_dir,"testdata")
89
_tree_construction=os.path.join(_testdata,"tree-construction")
910
_tokenizer=os.path.join(_testdata,"tokenizer")
11+
_sanitizer_testdata=os.path.join(_dir,"sanitizer-testdata")
1012

1113

1214
defpytest_collectstart():
@@ -24,3 +26,6 @@ def pytest_collect_file(path, parent):
2426
elifdir==_tokenizer:
2527
ifpath.ext==".test":
2628
returnTokenizerFile(path,parent)
29+
elifdir==_sanitizer_testdata:
30+
ifpath.ext==".dat":
31+
returnSanitizerFile(path,parent)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp