Skip to content

Commit

Permalink
Merge ahielg:master for attribute fix
Browse files Browse the repository at this point in the history
Fixes #746
  • Loading branch information
jhy committed Aug 19, 2016
1 parent aa81e10 commit f0f0e41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Expand Up @@ -29,6 +29,9 @@ jsoup changelog
* Fixed an OOB exception when loading an empty-body URL and parsing with the XML parser.
<https://github.com/jhy/jsoup/issues/727>

* Fixed an issue where attribute names starting with a slash would be parsed incorrectly.
<https://github.com/jhy/jsoup/pull/748>

*** Release 1.9.2 [2016-May-17]
* Fixed an issue where tag names that contained non-ascii characters but started with an ascii character
would cause the parser to get stuck in an infinite loop.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jsoup/parser/TokeniserState.java
Expand Up @@ -880,6 +880,7 @@ void read(Tokeniser t, CharacterReader r) {
break;
default:
t.error(this);
r.unconsume();
t.transition(BeforeAttributeName);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/jsoup/parser/AttributeParseTest.java
Expand Up @@ -6,6 +6,7 @@
import org.jsoup.nodes.Attribute;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.BooleanAttribute;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.junit.Test;
Expand Down Expand Up @@ -90,4 +91,13 @@ public class AttributeParseTest {
assertEquals(html, el.outerHtml());
}

@Test public void dropsSlashFromAttributeName() {
String html = "<img /onerror='doMyJob'/>";
Document doc = Jsoup.parse(html);
assertTrue("SelfClosingStartTag ignores last character", doc.select("img[onerror]").size() != 0);
assertEquals("<img onerror=\"doMyJob\">", doc.body().html());

doc = Jsoup.parse(html, "", Parser.xmlParser());
assertEquals("<img onerror=\"doMyJob\" />", doc.html());
}
}

0 comments on commit f0f0e41

Please sign in to comment.