Skip to content

Commit b86beca

Browse files
author
tomjohan
committed
Keep tag that have not been closed by > before reaching EOF.
1 parent 9e97fbf commit b86beca

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/java/org/jsoup/parser/TokeniserState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ void read(Tokeniser t, CharacterReader r) {
757757
break;
758758
case eof:
759759
t.eofError(this);
760+
t.emitTagPending();
760761
t.transition(Data);
761762
break;
762763
case '>':

src/test/java/org/jsoup/parser/XmlTreeBuilderTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,11 @@ public void testDoesNotForceSelfClosingKnownTags() {
121121
Document doc = Jsoup.parse("x", "", Parser.xmlParser());
122122
assertEquals(Syntax.xml, doc.outputSettings().syntax());
123123
}
124+
125+
@Test
126+
public void testDoesHandleEOFInTag() {
127+
String html = "<img src=asdf onerror=\"alert(1)\" x=";
128+
Document xmlDoc = Jsoup.parse(html, "", Parser.xmlParser());
129+
assertEquals("<img src=\"asdf\" onerror=\"alert(1)\" x=\"\" />", xmlDoc.html());
130+
}
124131
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy