-
Notifications
You must be signed in to change notification settings - Fork 25
Prevent SelfClosingSVGElements document filter from erroneously self-closing tags
#513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tests/Dom/DocumentTest.php
Outdated
| '<!DOCTYPE html><html>' . $head . '<body>' . PHP_EOL | ||
| . '<svg>' . PHP_EOL | ||
| . ' <g id="ok">' . PHP_EOL | ||
| . ' <path/>' . PHP_EOL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently failing in assertSimilarMarkup:
1) AmpProject\Dom\DocumentTest::testSVGSelfClosingElements with data set "test g tag one path child and newlines" ('<!DOCTYPE html><html><head></.../html>', '<!DOCTYPE html><html><head><m.../html>')
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
5 => '<body>'
6 => '<svg>'
7 => '<g id="ok">'
- 8 => '<path/>'
+ 8 => '<path>'
9 => '</g>'
10 => '</svg>'
11 => '</body>'
12 => '</html>'
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in cb091ed by using assertEqualMarkup instead of assertSimilarMarkup.
|
@schlessera Once this is merged, can a 0.11.0 release be made so we can include it in AMP plugin v2.2.2? |
|
|
||
| if (null === $regexPattern) { | ||
| $regexPattern = '#<(' . implode('|', self::SELF_CLOSING_TAGS) . ')((?>\s+[^/>]*))/?>(?!.*</\1>)#i'; | ||
| $regexPattern = '#<(' . implode('|', self::SELF_CLOSING_TAGS) . ')((?>\s*[^/>]*))/?>(?!.*</\1>)#is'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously .* would stop processing once it got to the end of a line. Now it will continue on to the end of the document. So that is something to be wary of.
Fixes #512
Ensures that
SelfClosingSVGElementswill properly process:<path/>as opposed to<path />).