<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[178128] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/178128">178128</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2015-01-08 13:12:08 -0800 (Thu, 08 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>ASSERTION FAILED: character != kEndOfFileMarker in WebCore::HTMLTokenizer::bufferCharacter
https://bugs.webkit.org/show_bug.cgi?id=140179

Reviewed by Anders Carlsson.

Source/WebCore:

Test: fast/parser/numeric-entities.html

* html/parser/HTMLEntityParser.cpp:
(WebCore::HTMLEntityParser::legalEntityFor): Merged adjustEntity logic in here.
Since the type UChar32 is a signed integer, need to check for &lt;= 0, not just 0.
This &lt;= change alone would have fixed the bug.

* xml/parser/CharacterReferenceParserInlines.h:
(WebCore::consumeCharacterReference): Added overflow checking when parsing hex
and decimal character references. This change alone would also have fixed the
bug, but in addition it makes overflow cases reliably generate replacement
characters rather than ignoring the overflow and producing seemingly random
characters. Test cases cover the original reported bug and other overflow cases.

LayoutTests:

* fast/parser/numeric-entities-expected.txt: Added.
* fast/parser/numeric-entities.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLEntityParsercpp">trunk/Source/WebCore/html/parser/HTMLEntityParser.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlparserCharacterReferenceParserInlinesh">trunk/Source/WebCore/xml/parser/CharacterReferenceParserInlines.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastparsernumericentitiesexpectedtxt">trunk/LayoutTests/fast/parser/numeric-entities-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastparsernumericentitieshtml">trunk/LayoutTests/fast/parser/numeric-entities.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (178127 => 178128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-01-08 21:03:50 UTC (rev 178127)
+++ trunk/LayoutTests/ChangeLog        2015-01-08 21:12:08 UTC (rev 178128)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-01-08  Darin Adler  &lt;darin@apple.com&gt;
+
+        ASSERTION FAILED: character != kEndOfFileMarker in WebCore::HTMLTokenizer::bufferCharacter
+        https://bugs.webkit.org/show_bug.cgi?id=140179
+
+        Reviewed by Anders Carlsson.
+
+        * fast/parser/numeric-entities-expected.txt: Added.
+        * fast/parser/numeric-entities.html: Added.
+
</ins><span class="cx"> 2015-01-08  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         After updating tests to use kerning, ligatures, and printer fonts, some tests fail
</span></span></pre></div>
<a id="trunkLayoutTestsfastparsernumericentitiesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/parser/numeric-entities-expected.txt (0 => 178128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/parser/numeric-entities-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/parser/numeric-entities-expected.txt        2015-01-08 21:12:08 UTC (rev 178128)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+PASS testEntity('&amp;#x0;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#x10000;') is &quot;0xD800, 0xDC00&quot;
+PASS testEntity('&amp;#x10FFFF;') is &quot;0xDBFF, 0xDFFF&quot;
+PASS testEntity('&amp;#x110000;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#xFFFFFF;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#xFFFFFFF;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#xFFFFFFFF;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#xFFFFFFFFF;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#xA0A103A0;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#x10000;') is &quot;0xD800, 0xDC00&quot;
+PASS testEntity('&amp;#x1000010000;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#1;') is &quot;0x1&quot;
+PASS testEntity('&amp;#11;') is &quot;0xB&quot;
+PASS testEntity('&amp;#111;') is &quot;0x6F&quot;
+PASS testEntity('&amp;#1111;') is &quot;0x457&quot;
+PASS testEntity('&amp;#11111;') is &quot;0x2B67&quot;
+PASS testEntity('&amp;#111111;') is &quot;0xD82C, 0xDE07&quot;
+PASS testEntity('&amp;#1111111;') is &quot;0xDBFD, 0xDC47&quot;
+PASS testEntity('&amp;#11111111;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#111111111;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#1111111111;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#11111111111;') is &quot;0xFFFD&quot;
+PASS testEntity('&amp;#x1;') is &quot;0x1&quot;
+PASS testEntity('&amp;#x9;') is &quot;0x9&quot;
+PASS testEntity('&amp;#xA;') is &quot;0xA&quot;
+PASS testEntity('&amp;#xB;') is &quot;0xB&quot;
+PASS testEntity('&amp;#xC;') is &quot;0xC&quot;
+PASS testEntity('&amp;#xD;') is &quot;0xD&quot;
+PASS testEntity('&amp;#x7F;') is &quot;0x7F&quot;
+PASS testEntity('&amp;#x81;') is &quot;0x81&quot;
+PASS testEntity('&amp;#x8D;') is &quot;0x8D&quot;
+PASS testEntity('&amp;#x8F;') is &quot;0x8F&quot;
+PASS testEntity('&amp;#x90;') is &quot;0x90&quot;
+PASS testEntity('&amp;#x9D;') is &quot;0x9D&quot;
+PASS testEntity('&amp;#x80;') is &quot;0x20AC&quot;
+PASS testEntity('&amp;#x82;') is &quot;0x201A&quot;
+PASS testEntity('&amp;#x83;') is &quot;0x192&quot;
+PASS testEntity('&amp;#x84;') is &quot;0x201E&quot;
+PASS testEntity('&amp;#x85;') is &quot;0x2026&quot;
+PASS testEntity('&amp;#x86;') is &quot;0x2020&quot;
+PASS testEntity('&amp;#x87;') is &quot;0x2021&quot;
+PASS testEntity('&amp;#x88;') is &quot;0x2C6&quot;
+PASS testEntity('&amp;#x89;') is &quot;0x2030&quot;
+PASS testEntity('&amp;#x8A;') is &quot;0x160&quot;
+PASS testEntity('&amp;#x8B;') is &quot;0x2039&quot;
+PASS testEntity('&amp;#x8C;') is &quot;0x152&quot;
+PASS testEntity('&amp;#x8E;') is &quot;0x17D&quot;
+PASS testEntity('&amp;#x91;') is &quot;0x2018&quot;
+PASS testEntity('&amp;#x92;') is &quot;0x2019&quot;
+PASS testEntity('&amp;#x93;') is &quot;0x201C&quot;
+PASS testEntity('&amp;#x94;') is &quot;0x201D&quot;
+PASS testEntity('&amp;#x95;') is &quot;0x2022&quot;
+PASS testEntity('&amp;#x96;') is &quot;0x2013&quot;
+PASS testEntity('&amp;#x97;') is &quot;0x2014&quot;
+PASS testEntity('&amp;#x98;') is &quot;0x2DC&quot;
+PASS testEntity('&amp;#x99;') is &quot;0x2122&quot;
+PASS testEntity('&amp;#x9A;') is &quot;0x161&quot;
+PASS testEntity('&amp;#x9B;') is &quot;0x203A&quot;
+PASS testEntity('&amp;#x9C;') is &quot;0x153&quot;
+PASS testEntity('&amp;#x9E;') is &quot;0x17E&quot;
+PASS testEntity('&amp;#x9F;') is &quot;0x178&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastparsernumericentitieshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/parser/numeric-entities.html (0 => 178128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/parser/numeric-entities.html                                (rev 0)
+++ trunk/LayoutTests/fast/parser/numeric-entities.html        2015-01-08 21:12:08 UTC (rev 178128)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function testEntity(entity)
+{
+    var element = document.createElement(&quot;div&quot;)
+    element.innerHTML = entity;
+    var string = element.firstChild.data;
+    var result = &quot;&quot;;
+    for (var i = 0; i &lt; string.length; ++i) {
+        if (result.length)
+            result += &quot;, &quot;
+        result += &quot;0x&quot; + string.charCodeAt(i).toString(16).toUpperCase();
+    }
+    return result;
+}
+
+shouldBeEqualToString(&quot;testEntity('&amp;#x0;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x10000;')&quot;, &quot;0xD800, 0xDC00&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x10FFFF;')&quot;, &quot;0xDBFF, 0xDFFF&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x110000;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xFFFFFF;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xFFFFFFF;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xFFFFFFFF;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xFFFFFFFFF;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xA0A103A0;')&quot;, &quot;0xFFFD&quot;);
+
+shouldBeEqualToString(&quot;testEntity('&amp;#x10000;')&quot;, &quot;0xD800, 0xDC00&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x1000010000;')&quot;, &quot;0xFFFD&quot;);
+
+shouldBeEqualToString(&quot;testEntity('&amp;#1;')&quot;, &quot;0x1&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#11;')&quot;, &quot;0xB&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#111;')&quot;, &quot;0x6F&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#1111;')&quot;, &quot;0x457&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#11111;')&quot;, &quot;0x2B67&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#111111;')&quot;, &quot;0xD82C, 0xDE07&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#1111111;')&quot;, &quot;0xDBFD, 0xDC47&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#11111111;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#111111111;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#1111111111;')&quot;, &quot;0xFFFD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#11111111111;')&quot;, &quot;0xFFFD&quot;);
+
+shouldBeEqualToString(&quot;testEntity('&amp;#x1;')&quot;, &quot;0x1&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9;')&quot;, &quot;0x9&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xA;')&quot;, &quot;0xA&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xB;')&quot;, &quot;0xB&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xC;')&quot;, &quot;0xC&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#xD;')&quot;, &quot;0xD&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x7F;')&quot;, &quot;0x7F&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x81;')&quot;, &quot;0x81&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x8D;')&quot;, &quot;0x8D&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x8F;')&quot;, &quot;0x8F&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x90;')&quot;, &quot;0x90&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9D;')&quot;, &quot;0x9D&quot;);
+
+shouldBeEqualToString(&quot;testEntity('&amp;#x80;')&quot;, &quot;0x20AC&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x82;')&quot;, &quot;0x201A&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x83;')&quot;, &quot;0x192&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x84;')&quot;, &quot;0x201E&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x85;')&quot;, &quot;0x2026&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x86;')&quot;, &quot;0x2020&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x87;')&quot;, &quot;0x2021&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x88;')&quot;, &quot;0x2C6&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x89;')&quot;, &quot;0x2030&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x8A;')&quot;, &quot;0x160&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x8B;')&quot;, &quot;0x2039&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x8C;')&quot;, &quot;0x152&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x8E;')&quot;, &quot;0x17D&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x91;')&quot;, &quot;0x2018&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x92;')&quot;, &quot;0x2019&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x93;')&quot;, &quot;0x201C&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x94;')&quot;, &quot;0x201D&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x95;')&quot;, &quot;0x2022&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x96;')&quot;, &quot;0x2013&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x97;')&quot;, &quot;0x2014&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x98;')&quot;, &quot;0x2DC&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x99;')&quot;, &quot;0x2122&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9A;')&quot;, &quot;0x161&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9B;')&quot;, &quot;0x203A&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9C;')&quot;, &quot;0x153&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9E;')&quot;, &quot;0x17E&quot;);
+shouldBeEqualToString(&quot;testEntity('&amp;#x9F;')&quot;, &quot;0x178&quot;);
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (178127 => 178128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-08 21:03:50 UTC (rev 178127)
+++ trunk/Source/WebCore/ChangeLog        2015-01-08 21:12:08 UTC (rev 178128)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-01-08  Darin Adler  &lt;darin@apple.com&gt;
+
+        ASSERTION FAILED: character != kEndOfFileMarker in WebCore::HTMLTokenizer::bufferCharacter
+        https://bugs.webkit.org/show_bug.cgi?id=140179
+
+        Reviewed by Anders Carlsson.
+
+        Test: fast/parser/numeric-entities.html
+
+        * html/parser/HTMLEntityParser.cpp:
+        (WebCore::HTMLEntityParser::legalEntityFor): Merged adjustEntity logic in here.
+        Since the type UChar32 is a signed integer, need to check for &lt;= 0, not just 0.
+        This &lt;= change alone would have fixed the bug.
+
+        * xml/parser/CharacterReferenceParserInlines.h:
+        (WebCore::consumeCharacterReference): Added overflow checking when parsing hex
+        and decimal character references. This change alone would also have fixed the
+        bug, but in addition it makes overflow cases reliably generate replacement
+        characters rather than ignoring the overflow and producing seemingly random
+        characters. Test cases cover the original reported bug and other overflow cases.
+
</ins><span class="cx"> 2015-01-08  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Text not drawn or white-on-white for &quot;Close Page&quot;/&quot;Go Back&quot; button on safe browsing warning page
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLEntityParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLEntityParser.cpp (178127 => 178128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLEntityParser.cpp        2015-01-08 21:03:50 UTC (rev 178127)
+++ trunk/Source/WebCore/html/parser/HTMLEntityParser.cpp        2015-01-08 21:12:08 UTC (rev 178128)
</span><span class="lines">@@ -51,23 +51,15 @@
</span><span class="cx"> 
</span><span class="cx"> class HTMLEntityParser {
</span><span class="cx"> public:
</span><del>-    inline static UChar adjustEntity(UChar32 value)
</del><ins>+    static UChar32 legalEntityFor(UChar32 value)
</ins><span class="cx">     {
</span><del>-        if ((value &amp; ~0x1F) != 0x0080)
</del><ins>+        if (value &lt;= 0 || value &gt; 0x10FFFF || (value &gt;= 0xD800 &amp;&amp; value &lt;= 0xDFFF))
+            return 0xFFFD;
+        if ((value &amp; ~0x1F) != 0x80)
</ins><span class="cx">             return value;
</span><span class="cx">         return windowsLatin1ExtensionArray[value - 0x80];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    inline static UChar32 legalEntityFor(UChar32 value)
-    {
-        // FIXME: A number of specific entity values generate parse errors.
-        if (!value || value &gt; 0x10FFFF || (value &gt;= 0xD800 &amp;&amp; value &lt;= 0xDFFF))
-            return 0xFFFD;
-        if (U_IS_BMP(value))
-            return adjustEntity(value);
-        return value;
-    }
-
</del><span class="cx">     inline static bool acceptMalformed() { return true; }
</span><span class="cx"> 
</span><span class="cx">     inline static bool consumeNamedEntity(SegmentedString&amp; source, StringBuilder&amp; decodedEntity, bool&amp; notEnoughCharacters, UChar additionalAllowedCharacter, UChar&amp; cc)
</span></span></pre></div>
<a id="trunkSourceWebCorexmlparserCharacterReferenceParserInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/parser/CharacterReferenceParserInlines.h (178127 => 178128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/parser/CharacterReferenceParserInlines.h        2015-01-08 21:03:50 UTC (rev 178127)
+++ trunk/Source/WebCore/xml/parser/CharacterReferenceParserInlines.h        2015-01-08 21:12:08 UTC (rev 178128)
</span><span class="lines">@@ -65,6 +65,8 @@
</span><span class="cx">     };
</span><span class="cx">     EntityState entityState = Initial;
</span><span class="cx">     UChar32 result = 0;
</span><ins>+    bool overflow = false;
+    const UChar32 highestValidCharacter = 0x10FFFF;
</ins><span class="cx">     StringBuilder consumedCharacters;
</span><span class="cx">     
</span><span class="cx">     while (!source.isEmpty()) {
</span><span class="lines">@@ -128,15 +130,17 @@
</span><span class="cx">                 result = result * 16 + 10 + cc - 'A';
</span><span class="cx">             else if (cc == ';') {
</span><span class="cx">                 source.advanceAndASSERT(cc);
</span><del>-                decodedCharacter.append(ParserFunctions::legalEntityFor(result));
</del><ins>+                decodedCharacter.append(ParserFunctions::legalEntityFor(overflow ? 0 : result));
</ins><span class="cx">                 return true;
</span><span class="cx">             } else if (ParserFunctions::acceptMalformed()) {
</span><del>-                decodedCharacter.append(ParserFunctions::legalEntityFor(result));
</del><ins>+                decodedCharacter.append(ParserFunctions::legalEntityFor(overflow ? 0 : result));
</ins><span class="cx">                 return true;
</span><span class="cx">             } else {
</span><span class="cx">                 unconsumeCharacters(source, consumedCharacters);
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><ins>+            if (result &gt; highestValidCharacter)
+                overflow = true;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Decimal: {
</span><span class="lines">@@ -144,15 +148,17 @@
</span><span class="cx">                 result = result * 10 + cc - '0';
</span><span class="cx">             else if (cc == ';') {
</span><span class="cx">                 source.advanceAndASSERT(cc);
</span><del>-                decodedCharacter.append(ParserFunctions::legalEntityFor(result));
</del><ins>+                decodedCharacter.append(ParserFunctions::legalEntityFor(overflow ? 0 : result));
</ins><span class="cx">                 return true;
</span><span class="cx">             } else if (ParserFunctions::acceptMalformed()) {
</span><del>-                decodedCharacter.append(ParserFunctions::legalEntityFor(result));
</del><ins>+                decodedCharacter.append(ParserFunctions::legalEntityFor(overflow ? 0 : result));
</ins><span class="cx">                 return true;
</span><span class="cx">             } else {
</span><span class="cx">                 unconsumeCharacters(source, consumedCharacters);
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><ins>+            if (result &gt; highestValidCharacter)
+                overflow = true;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Named: {
</span></span></pre>
</div>
</div>

</body>
</html>