Skip to content

Commit

Permalink
fix regression from last release - the handling of self closing svg t…
Browse files Browse the repository at this point in the history
…ags was broken
  • Loading branch information
rbri committed Jan 30, 2024
1 parent 9cf48df commit 27dd64a
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 12 deletions.
12 changes: 5 additions & 7 deletions src/main/java/org/htmlunit/cyberneko/HTMLScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2889,13 +2889,11 @@ else if (fByteStream != null && "BODY".equalsIgnoreCase(ename)) {
fByteStream = null;
}
else {
final HTMLElements.Element element = htmlConfiguration_.getHtmlElements().getElement(ename);
if (element.code == HTMLElements.UNKNOWN) {
empty[0] = false;
}

if (fByteStream != null && element.parent != null && element.parent.length > 0) {
if (element.parent[0].code == HTMLElements.BODY) {
if (fByteStream != null) {
final HTMLElements.Element element = htmlConfiguration_.getHtmlElements().getElement(ename);
if (element.parent != null
&& element.parent.length > 0
&& element.parent[0].code == HTMLElements.BODY) {
fByteStream.clear();
fByteStream = null;
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/htmlunit/cyberneko/CanonicalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void runTest(final File dataFile) throws Exception {
fail("Canonical file not found for input: " + dataFile.getAbsolutePath() + ": " + dataLines);
}

final File nyiFile = new File(dataFile.getParentFile(), dataFile.getName() + ".notyetimplemented");
final File nyiFile = new File(canonicalFile.getParentFile(), canonicalFile.getName() + ".nyi");
if (nyiFile.exists()) {
try {
assertEquals(getCanonical(canonicalFile), dataLines, dataFile.toString());
Expand Down Expand Up @@ -167,7 +167,7 @@ public void runDomTest(final File dataFile) throws Exception {
fail("Canonical file not found for input: " + dataFile.getAbsolutePath() + ": " + domDataLines);
}

final File nyiFile = new File(dataFile.getParentFile(), dataFile.getName() + ".notyetimplemented-dom");
final File nyiFile = new File(canonicalFile.getParentFile(), canonicalFile.getName() + ".nyi");
if (nyiFile.exists()) {
try {
assertEquals(getCanonical(canonicalFile), domDataLines, dataFile.toString());
Expand Down Expand Up @@ -224,7 +224,7 @@ public void runDomFragmentTest(final File dataFile) throws Exception {
fail("Canonical file not found for input: " + dataFile.getAbsolutePath() + ": " + domDataLines);
}

final File nyiFile = new File(dataFile.getParentFile(), dataFile.getName() + ".notyetimplemented-dom");
final File nyiFile = new File(canonicalFile.getParentFile(), canonicalFile.getName() + ".nyi");
if (nyiFile.exists()) {
try {
assertEquals(getCanonical(canonicalFile), domDataLines, dataFile.toString());
Expand All @@ -234,7 +234,7 @@ public void runDomFragmentTest(final File dataFile) throws Exception {
// expected
}

assertEquals(getCanonical(nyiFile).toLowerCase(Locale.ROOT), domDataLines, "NYI: " + dataFile);
assertEquals(getCanonical(nyiFile), domDataLines, "NYI: " + dataFile);
}
else {
assertEquals(getCanonical(canonicalFile), domDataLines, dataFile.toString());
Expand Down Expand Up @@ -273,7 +273,7 @@ public void runSaxTest(final File dataFile) throws Exception {
fail("Canonical file not found for input: " + dataFile.getAbsolutePath() + ": " + domDataLines);
}

final File nyiFile = new File(dataFile.getParentFile(), dataFile.getName() + ".notyetimplemented-dom");
final File nyiFile = new File(canonicalFile.getParentFile(), canonicalFile.getName() + ".nyi");
if (nyiFile.exists()) {
try {
assertEquals(getCanonical(canonicalFile), domDataLines, dataFile.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(select<style
)select<style
"k
(input<<
)input<<
"input/onfocus=alert(1)>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(HTML
(head
)head
(BODY
(select<style
)select<style
"k
(input<<
)input<<
"input/onfocus=alert(1)>
)BODY
)HTML
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(select<style
)select<style
"W
(xmp<script
"alert(1)
)xmp<script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(HTML
(head
)head
(BODY
(select<style
)select<style
"W
(xmp<script
"alert(1)
)xmp<script
)BODY
)HTML
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(select<style
)select<style
"k
(input<<
)input<<
"input/onfocus=alert(1)>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(HTML
(head
)head
(BODY
(select<style
)select<style
"k
(input<<
)input<<
"input/onfocus=alert(1)>
)BODY
)HTML
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><body><svg><path fill='#4285F4' /><path fill='#34A853'/></svg></body></html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(html
(head
)head
(body
(svg
(path
Afill #4285F4
)path
(path
Afill #34A853
)path
)svg
)body
)html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(html
(head
)head
(BODY
(foo
)foo
(title
"ti1234
)title
)BODY
)html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(html
(head
(unknown1
)unknown1
(title
"foo
)title
(unknown2
)unknown2
(unknown3
)unknown3
"\n
)head
)html

0 comments on commit 27dd64a

Please sign in to comment.