<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,6 @@
 use HTML::Entities qw(decode_entities encode_entities encode_entities_numeric);
 
-use Test::More tests =&gt; 16;
+use Test::More tests =&gt; 17;
 
 $a = &quot;V&amp;aring;re norske tegn b&amp;oslash;r &amp;#230res&quot;;
 
@@ -71,6 +71,8 @@ is(decode_entities(&quot;abc&amp;def&amp;ghi&amp;abc;&amp;def;&quot;), &quot;abc&amp;def&amp;ghi&amp;abc;&amp;def;&quot;);
 is(decode_entities(&quot;&amp;apos;&quot;), &quot;'&quot;);
 is(encode_entities(&quot;'&quot;, &quot;'&quot;), &quot;&amp;#39;&quot;);
 
+is(decode_entities(&quot;Attention Home&amp;#959&amp;#969n&amp;#1257rs...1&amp;#1109t T&amp;#1110&amp;#1084e E&amp;#957&amp;#1257&amp;#1075&quot;),
+  &quot;Attention Home\x{3BF}\x{3C9}n\x{4E9}rs...1\x{455}t T\x{456}\x{43C}e E\x{3BD}\x{4E9}\x{433}&quot;);
 
 __END__
 # Quoted from rfc1866.txt</diff>
      <filename>t/entities.t</filename>
    </modified>
    <modified>
      <diff>@@ -94,14 +94,14 @@ decode_entities(pTHX_ SV* sv, HV* entity2char, bool expand_prefix)
 	ent_start = s;
 	repl = 0;
 
-	if (*s == '#') {
+	if (s &lt; end &amp;&amp; *s == '#') {
 	    UV num = 0;
 	    UV prev = 0;
 	    int ok = 0;
 	    s++;
-	    if (*s == 'x' || *s == 'X') {
+	    if (s &lt; end &amp;&amp; (*s == 'x' || *s == 'X')) {
 		s++;
-		while (*s) {
+		while (s &lt; end) {
 		    char *tmp = strchr(PL_hexdigit, *s);
 		    if (!tmp)
 			break;
@@ -117,7 +117,7 @@ decode_entities(pTHX_ SV* sv, HV* entity2char, bool expand_prefix)
 		}
 	    }
 	    else {
-		while (isDIGIT(*s)) {
+		while (s &lt; end &amp;&amp; isDIGIT(*s)) {
 		    num = num * 10 + (*s - '0');
 		    if (prev &amp;&amp; num &lt; prev) {
 			/* overflow */
@@ -180,7 +180,7 @@ decode_entities(pTHX_ SV* sv, HV* entity2char, bool expand_prefix)
 	}
 	else {
 	    char *ent_name = s;
-	    while (isALNUM(*s))
+	    while (s &lt; end &amp;&amp; isALNUM(*s))
 		s++;
 	    if (ent_name != s &amp;&amp; entity2char) {
 		SV** svp;
@@ -216,7 +216,7 @@ decode_entities(pTHX_ SV* sv, HV* entity2char, bool expand_prefix)
 
 	if (repl) {
 	    char *repl_allocated = 0;
-	    if (*s == ';')
+	    if (s &lt; end &amp;&amp; *s == ';')
 		s++;
 	    t--;  /* '&amp;' already copied, undo it */
 </diff>
      <filename>util.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6e91cf4085db4f8518d7979aef4ae9b22551ad39</id>
    </parent>
  </parents>
  <author>
    <name>Gisle Aas</name>
    <login>gisle</login>
    <email>gisle@aas.no</email>
  </author>
  <url>http://github.com/gisle/html-parser/commit/b9aae1e43eb2c8e989510187cff0ba3e996f9a4c</url>
  <id>b9aae1e43eb2c8e989510187cff0ba3e996f9a4c</id>
  <committed-date>2009-10-22T12:49:23-07:00</committed-date>
  <authored-date>2009-10-22T12:45:54-07:00</authored-date>
  <message>decode_entities confused by trailing incomplete entity

Mark Martinec reported crashed when running SpamAssassin, given a
particular HTML junk mail to parse.  The problem was caused by
HTML::Parsers decode_entities function confusing itself when it
encountered strings with incomplete entities at the end of the string.</message>
  <tree>ece3933713076e76cb9105ecd2064ab0da885679</tree>
  <committer>
    <name>Gisle Aas</name>
    <login>gisle</login>
    <email>gisle@aas.no</email>
  </committer>
</commit>
