<!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>[202599] 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/202599">202599</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-06-28 18:04:05 -0700 (Tue, 28 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement &quot;replacement&quot; codec
https://bugs.webkit.org/show_bug.cgi?id=159180
&lt;rdar://problem/26015178&gt;

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt:

Source/WebCore:

Test: fast/encoding/charset-replacement.html

Add support for &quot;replacement&quot; codec according to the spec:
https://encoding.spec.whatwg.org/#replacement
According to the spec, encoding labels {&quot;csiso2022kr&quot;, &quot;hz-gb-2312&quot;, &quot;iso-2022-cn&quot;,
&quot;iso-2022-cn-ext&quot;, &quot;iso-2022-kr&quot;} are used to conduct certain attacks that abuse
a mismatch between encodings supported on the server and the client. Therefore,
they are grouped under the &quot;replacement&quot; codec, which does the following things
to prevent those attacks.
1) Decode: terminates with a single U+FFFD.
2) Encode: treated as UTF-8.

Furthermore, the &quot;replacement&quot; codec is a specification convenience to group those
vulnerable encoding labels. Therefore, it should not be able to use directly.

This change is based on the following Blink changes:
https://codereview.chromium.org/265973003, and
https://codereview.chromium.org/261013007.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/text/TextAllInOne.cpp:
* platform/text/TextCodecReplacement.cpp: Added.
(WebCore::TextCodecReplacement::create):
(WebCore::TextCodecReplacement::TextCodecReplacement):
(WebCore::TextCodecReplacement::registerEncodingNames):
(WebCore::TextCodecReplacement::registerCodecs):
(WebCore::TextCodecReplacement::decode):
* platform/text/TextCodecReplacement.h: Added.
* platform/text/TextEncoding.cpp:
(WebCore::TextEncoding::TextEncoding):
* platform/text/TextEncodingRegistry.cpp:
(WebCore::isReplacementEncoding):
(WebCore::extendTextCodecMaps):
* platform/text/TextEncodingRegistry.h:

LayoutTests:

* fast/encoding/char-decoding-expected.txt:
* fast/encoding/char-decoding.html:
* fast/encoding/char-encoding-expected.txt:
* fast/encoding/char-encoding.html:
* fast/encoding/charset-replacement-expected.txt: Added.
* fast/encoding/charset-replacement.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastencodingchardecodingexpectedtxt">trunk/LayoutTests/fast/encoding/char-decoding-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastencodingchardecodinghtml">trunk/LayoutTests/fast/encoding/char-decoding.html</a></li>
<li><a href="#trunkLayoutTestsfastencodingcharencodingexpectedtxt">trunk/LayoutTests/fast/encoding/char-encoding-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastencodingcharencodinghtml">trunk/LayoutTests/fast/encoding/char-encoding.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomnodesDocumentcharacterSetnormalizationexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextAllInOnecpp">trunk/Source/WebCore/platform/text/TextAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextEncodingcpp">trunk/Source/WebCore/platform/text/TextEncoding.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextEncodingRegistrycpp">trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextEncodingRegistryh">trunk/Source/WebCore/platform/text/TextEncodingRegistry.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastencodingcharsetreplacementexpectedtxt">trunk/LayoutTests/fast/encoding/charset-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastencodingcharsetreplacementhtml">trunk/LayoutTests/fast/encoding/charset-replacement.html</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextCodecReplacementcpp">trunk/Source/WebCore/platform/text/TextCodecReplacement.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextCodecReplacementh">trunk/Source/WebCore/platform/text/TextCodecReplacement.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/ChangeLog        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-06-28  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Implement &quot;replacement&quot; codec
+        https://bugs.webkit.org/show_bug.cgi?id=159180
+        &lt;rdar://problem/26015178&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * fast/encoding/char-decoding-expected.txt:
+        * fast/encoding/char-decoding.html:
+        * fast/encoding/char-encoding-expected.txt:
+        * fast/encoding/char-encoding.html:
+        * fast/encoding/charset-replacement-expected.txt: Added.
+        * fast/encoding/charset-replacement.html: Added.
+
</ins><span class="cx"> 2016-06-28  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r200946): Improper backtracking from last alternative in sticky patterns
</span></span></pre></div>
<a id="trunkLayoutTestsfastencodingchardecodingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/encoding/char-decoding-expected.txt (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/encoding/char-decoding-expected.txt        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/fast/encoding/char-decoding-expected.txt        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -190,6 +190,11 @@
</span><span class="cx"> PASS decode('csUnicode', '%69%D8%D6%DE') is 'U+D869/U+DED6'
</span><span class="cx"> PASS decode('UTF-16BE', '%D8%69%DE%D6') is 'U+D869/U+DED6'
</span><span class="cx"> PASS decode('unicodeFFFE', '%D8%69%DE%D6') is 'U+D869/U+DED6'
</span><ins>+PASS decode('csiso2022kr', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD'
+PASS decode('hz-gb-2312', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD'
+PASS decode('iso-2022-cn', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD'
+PASS decode('iso-2022-cn-ext', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD'
+PASS decode('iso-2022-kr', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD'
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastencodingchardecodinghtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/encoding/char-decoding.html (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/encoding/char-decoding.html        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/fast/encoding/char-decoding.html        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -105,6 +105,13 @@
</span><span class="cx"> testDecode('UTF-16BE', '%D8%69%DE%D6', 'U+D869/U+DED6');
</span><span class="cx"> testDecode('unicodeFFFE', '%D8%69%DE%D6', 'U+D869/U+DED6');
</span><span class="cx"> 
</span><ins>+// Replacement encodings should decode as replacement (U+FFFD) then EOF
+testDecode(&quot;csiso2022kr&quot;, &quot;%41%42%43%61%62%63%31%32%33%A0&quot;, &quot;U+FFFD&quot;);
+testDecode(&quot;hz-gb-2312&quot;, &quot;%41%42%43%61%62%63%31%32%33%A0&quot;, &quot;U+FFFD&quot;);
+testDecode(&quot;iso-2022-cn&quot;, &quot;%41%42%43%61%62%63%31%32%33%A0&quot;, &quot;U+FFFD&quot;);
+testDecode(&quot;iso-2022-cn-ext&quot;, &quot;%41%42%43%61%62%63%31%32%33%A0&quot;, &quot;U+FFFD&quot;);
+testDecode(&quot;iso-2022-kr&quot;, &quot;%41%42%43%61%62%63%31%32%33%A0&quot;, &quot;U+FFFD&quot;);
+
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastencodingcharencodingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/encoding/char-encoding-expected.txt (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/encoding/char-encoding-expected.txt        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/fast/encoding/char-encoding-expected.txt        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -16,6 +16,11 @@
</span><span class="cx"> PASS encode('GBK', 'U+1E3F') is '%A8%BC'
</span><span class="cx"> PASS encode('GBK', 'U+22EF') is '%A1%AD'
</span><span class="cx"> PASS encode('GBK', 'U+301C') is '%A1%AB'
</span><ins>+PASS encode('csiso2022kr', 'U+00A0') is '%C2%A0'
+PASS encode('hz-gb-2312', 'U+00A0') is '%C2%A0'
+PASS encode('iso-2022-cn', 'U+00A0') is '%C2%A0'
+PASS encode('iso-2022-cn-ext', 'U+00A0') is '%C2%A0'
+PASS encode('iso-2022-kr', 'U+00A0') is '%C2%A0'
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastencodingcharencodinghtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/encoding/char-encoding.html (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/encoding/char-encoding.html        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/fast/encoding/char-encoding.html        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -33,6 +33,12 @@
</span><span class="cx"> testEncode('GBK', 'U+1E3F', '%A8%BC');
</span><span class="cx"> testEncode('GBK', 'U+22EF', '%A1%AD');
</span><span class="cx"> testEncode('GBK', 'U+301C', '%A1%AB');
</span><ins>+// Replacement encodings - should encode as UTF-8
+testEncode(&quot;csiso2022kr&quot;, &quot;U+00A0&quot;, &quot;%C2%A0&quot;);
+testEncode(&quot;hz-gb-2312&quot;, &quot;U+00A0&quot;, &quot;%C2%A0&quot;);
+testEncode(&quot;iso-2022-cn&quot;, &quot;U+00A0&quot;, &quot;%C2%A0&quot;);
+testEncode(&quot;iso-2022-cn-ext&quot;, &quot;U+00A0&quot;, &quot;%C2%A0&quot;);
+testEncode(&quot;iso-2022-kr&quot;, &quot;U+00A0&quot;, &quot;%C2%A0&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Turning on this test causes a download to occur. FIXME: A bug?
</span><span class="cx"> // testEncode('UTF-8', 'U+221A', '%E2%88%9A');
</span></span></pre></div>
<a id="trunkLayoutTestsfastencodingcharsetreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/encoding/charset-replacement-expected.txt (0 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/encoding/charset-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/encoding/charset-replacement-expected.txt        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+ALERT: ISO-8859-1
+Test PASSED if the encoding of this document is the default encoding.
+Test FAILED if you see a U+FFFD character in a dumped render tree.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastencodingcharsetreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/encoding/charset-replacement.html (0 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/encoding/charset-replacement.html                                (rev 0)
+++ trunk/LayoutTests/fast/encoding/charset-replacement.html        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;meta charset=rEpLaCeMeNt&gt;
+    &lt;script&gt;
+    if (window.testRunner)
+        testRunner.dumpAsText();
+    alert(document.characterSet);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    Test PASSED if the encoding of this document is the default encoding.&lt;br&gt;
+    Test FAILED if you see a U+FFFD character in a dumped render tree.&lt;br&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-06-28  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Implement &quot;replacement&quot; codec
+        https://bugs.webkit.org/show_bug.cgi?id=159180
+        &lt;rdar://problem/26015178&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt:
+
</ins><span class="cx"> 2016-06-27  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove didFailAccessControlCheck ThreadableLoaderClient callback
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomnodesDocumentcharacterSetnormalizationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -638,19 +638,19 @@
</span><span class="cx"> PASS Name &quot;EUC-KR&quot; has label &quot;windows-949&quot; (characterSet) 
</span><span class="cx"> PASS Name &quot;EUC-KR&quot; has label &quot;windows-949&quot; (inputEncoding) 
</span><span class="cx"> PASS Name &quot;EUC-KR&quot; has label &quot;windows-949&quot; (charset) 
</span><del>-FAIL Name &quot;replacement&quot; has label &quot;csiso2022kr&quot; (characterSet) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-KR&quot;
-FAIL Name &quot;replacement&quot; has label &quot;csiso2022kr&quot; (inputEncoding) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-KR&quot;
-FAIL Name &quot;replacement&quot; has label &quot;csiso2022kr&quot; (charset) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-KR&quot;
-FAIL Name &quot;replacement&quot; has label &quot;hz-gb-2312&quot; (characterSet) assert_equals: expected &quot;replacement&quot; but got &quot;HZ-GB-2312&quot;
-FAIL Name &quot;replacement&quot; has label &quot;hz-gb-2312&quot; (inputEncoding) assert_equals: expected &quot;replacement&quot; but got &quot;HZ-GB-2312&quot;
-FAIL Name &quot;replacement&quot; has label &quot;hz-gb-2312&quot; (charset) assert_equals: expected &quot;replacement&quot; but got &quot;HZ-GB-2312&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-cn&quot; (characterSet) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-CN&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-cn&quot; (inputEncoding) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-CN&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-cn&quot; (charset) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-CN&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-cn-ext&quot; (characterSet) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-CN-EXT&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-cn-ext&quot; (inputEncoding) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-CN-EXT&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-cn-ext&quot; (charset) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-CN-EXT&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-kr&quot; (characterSet) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-KR&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-kr&quot; (inputEncoding) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-KR&quot;
-FAIL Name &quot;replacement&quot; has label &quot;iso-2022-kr&quot; (charset) assert_equals: expected &quot;replacement&quot; but got &quot;ISO-2022-KR&quot;
</del><ins>+PASS Name &quot;replacement&quot; has label &quot;csiso2022kr&quot; (characterSet) 
+PASS Name &quot;replacement&quot; has label &quot;csiso2022kr&quot; (inputEncoding) 
+PASS Name &quot;replacement&quot; has label &quot;csiso2022kr&quot; (charset) 
+PASS Name &quot;replacement&quot; has label &quot;hz-gb-2312&quot; (characterSet) 
+PASS Name &quot;replacement&quot; has label &quot;hz-gb-2312&quot; (inputEncoding) 
+PASS Name &quot;replacement&quot; has label &quot;hz-gb-2312&quot; (charset) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-cn&quot; (characterSet) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-cn&quot; (inputEncoding) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-cn&quot; (charset) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-cn-ext&quot; (characterSet) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-cn-ext&quot; (inputEncoding) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-cn-ext&quot; (charset) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-kr&quot; (characterSet) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-kr&quot; (inputEncoding) 
+PASS Name &quot;replacement&quot; has label &quot;iso-2022-kr&quot; (charset) 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -2378,6 +2378,7 @@
</span><span class="cx">     platform/text/TextCodec.cpp
</span><span class="cx">     platform/text/TextCodecICU.cpp
</span><span class="cx">     platform/text/TextCodecLatin1.cpp
</span><ins>+    platform/text/TextCodecReplacement.cpp
</ins><span class="cx">     platform/text/TextCodecUTF16.cpp
</span><span class="cx">     platform/text/TextCodecUTF8.cpp
</span><span class="cx">     platform/text/TextCodecUserDefined.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/ChangeLog        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2016-06-28  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Implement &quot;replacement&quot; codec
+        https://bugs.webkit.org/show_bug.cgi?id=159180
+        &lt;rdar://problem/26015178&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Test: fast/encoding/charset-replacement.html
+
+        Add support for &quot;replacement&quot; codec according to the spec:
+        https://encoding.spec.whatwg.org/#replacement
+        According to the spec, encoding labels {&quot;csiso2022kr&quot;, &quot;hz-gb-2312&quot;, &quot;iso-2022-cn&quot;,
+        &quot;iso-2022-cn-ext&quot;, &quot;iso-2022-kr&quot;} are used to conduct certain attacks that abuse
+        a mismatch between encodings supported on the server and the client. Therefore,
+        they are grouped under the &quot;replacement&quot; codec, which does the following things
+        to prevent those attacks.
+        1) Decode: terminates with a single U+FFFD.
+        2) Encode: treated as UTF-8.
+
+        Furthermore, the &quot;replacement&quot; codec is a specification convenience to group those
+        vulnerable encoding labels. Therefore, it should not be able to use directly.
+
+        This change is based on the following Blink changes:
+        https://codereview.chromium.org/265973003, and
+        https://codereview.chromium.org/261013007.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/text/TextAllInOne.cpp:
+        * platform/text/TextCodecReplacement.cpp: Added.
+        (WebCore::TextCodecReplacement::create):
+        (WebCore::TextCodecReplacement::TextCodecReplacement):
+        (WebCore::TextCodecReplacement::registerEncodingNames):
+        (WebCore::TextCodecReplacement::registerCodecs):
+        (WebCore::TextCodecReplacement::decode):
+        * platform/text/TextCodecReplacement.h: Added.
+        * platform/text/TextEncoding.cpp:
+        (WebCore::TextEncoding::TextEncoding):
+        * platform/text/TextEncodingRegistry.cpp:
+        (WebCore::isReplacementEncoding):
+        (WebCore::extendTextCodecMaps):
+        * platform/text/TextEncodingRegistry.h:
+
</ins><span class="cx"> 2016-06-28  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove incorrect comments in HTMLCanvasElement
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -2331,6 +2331,8 @@
</span><span class="cx">                 555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
</span><span class="cx">                 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
</span><span class="cx">                 572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
</span><ins>+                57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */; };
+                57EF5E621D20D28700171E60 /* TextCodecReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */; };
</ins><span class="cx">                 580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5803715F1A66F00A00BAF519 /* ClipRect.cpp */; };
</span><span class="cx">                 580371621A66F00A00BAF519 /* ClipRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371601A66F00A00BAF519 /* ClipRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 580371641A66F1D300BAF519 /* LayerFragment.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371631A66F1D300BAF519 /* LayerFragment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -9997,6 +9999,8 @@
</span><span class="cx">                 55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecReplacement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecReplacement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 580371601A66F00A00BAF519 /* ClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipRect.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 580371631A66F1D300BAF519 /* LayerFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFragment.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -22349,6 +22353,8 @@
</span><span class="cx">                                 B2C3DA0C0D006C1D00EF6F26 /* TextCodecICU.h */,
</span><span class="cx">                                 B2C3DA0D0D006C1D00EF6F26 /* TextCodecLatin1.cpp */,
</span><span class="cx">                                 B2C3DA0E0D006C1D00EF6F26 /* TextCodecLatin1.h */,
</span><ins>+                                57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */,
+                                57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */,
</ins><span class="cx">                                 B2C3DA0F0D006C1D00EF6F26 /* TextCodecUserDefined.cpp */,
</span><span class="cx">                                 B2C3DA100D006C1D00EF6F26 /* TextCodecUserDefined.h */,
</span><span class="cx">                                 B2C3DA110D006C1D00EF6F26 /* TextCodecUTF16.cpp */,
</span><span class="lines">@@ -27911,6 +27917,7 @@
</span><span class="cx">                                 BC3BE9950E9C1C7C00835588 /* RenderScrollbarPart.h in Headers */,
</span><span class="cx">                                 BC3BE9990E9C1E5D00835588 /* RenderScrollbarTheme.h in Headers */,
</span><span class="cx">                                 458FE40A1589DF0B005609E6 /* RenderSearchField.h in Headers */,
</span><ins>+                                57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */,
</ins><span class="cx">                                 0F11A54F0F39233100C37884 /* RenderSelectionInfo.h in Headers */,
</span><span class="cx">                                 AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */,
</span><span class="cx">                                 31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */,
</span><span class="lines">@@ -30189,6 +30196,7 @@
</span><span class="cx">                                 F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */,
</span><span class="cx">                                 D359D789129CA2710006E5D2 /* HTMLDetailsElement.cpp in Sources */,
</span><span class="cx">                                 A8EA79F90A1916DF00A8EF5F /* HTMLDirectoryElement.cpp in Sources */,
</span><ins>+                                57EF5E621D20D28700171E60 /* TextCodecReplacement.cpp in Sources */,
</ins><span class="cx">                                 A8EA7CB10A192B9C00A8EF5F /* HTMLDivElement.cpp in Sources */,
</span><span class="cx">                                 A8EA79F50A1916DF00A8EF5F /* HTMLDListElement.cpp in Sources */,
</span><span class="cx">                                 93F19A9108245E59001E9ABC /* HTMLDocument.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextAllInOne.cpp (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextAllInOne.cpp        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/platform/text/TextAllInOne.cpp        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;TextCodec.cpp&quot;
</span><span class="cx"> #include &quot;TextCodecICU.cpp&quot;
</span><span class="cx"> #include &quot;TextCodecLatin1.cpp&quot;
</span><ins>+#include &quot;TextCodecReplacement.cpp&quot;
</ins><span class="cx"> #include &quot;TextCodecUTF16.cpp&quot;
</span><span class="cx"> #include &quot;TextCodecUTF8.cpp&quot;
</span><span class="cx"> #include &quot;TextCodecUserDefined.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextCodecReplacementcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/text/TextCodecReplacement.cpp (0 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextCodecReplacement.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/text/TextCodecReplacement.cpp        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;TextCodecReplacement.h&quot;
+
+namespace WebCore {
+
+static const UChar ReplacementCharacter[1] = { 0xFFFD };
+
+std::unique_ptr&lt;TextCodec&gt; TextCodecReplacement::create(const TextEncoding&amp;, const void*)
+{
+    return std::make_unique&lt;TextCodecReplacement&gt;();
+}
+
+TextCodecReplacement::TextCodecReplacement()
+{
+}
+
+void TextCodecReplacement::registerEncodingNames(EncodingNameRegistrar registrar)
+{
+    // The 'replacement' itself is not a valid label. It is the name of
+    // a group of legacy encoding labels. Hence, it cannot be used directly.
+    registrar(&quot;replacement&quot;, &quot;replacement&quot;);
+
+    // The labels
+    registrar(&quot;csiso2022kr&quot;, &quot;replacement&quot;);
+    registrar(&quot;hz-gb-2312&quot;, &quot;replacement&quot;);
+    registrar(&quot;iso-2022-cn&quot;, &quot;replacement&quot;);
+    registrar(&quot;iso-2022-cn-ext&quot;, &quot;replacement&quot;);
+    registrar(&quot;iso-2022-kr&quot;, &quot;replacement&quot;);
+}
+
+void TextCodecReplacement::registerCodecs(TextCodecRegistrar registrar)
+{
+    registrar(&quot;replacement&quot;, create, 0);
+}
+
+String TextCodecReplacement::decode(const char*, size_t, bool, bool, bool&amp; sawError)
+{
+    sawError = true;
+    if (m_sentEOF)
+        return emptyString();
+
+    m_sentEOF = true;
+    return ReplacementCharacter;
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextCodecReplacementh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/text/TextCodecReplacement.h (0 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextCodecReplacement.h                                (rev 0)
+++ trunk/Source/WebCore/platform/text/TextCodecReplacement.h        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TextCodecReplacement_h
+#define TextCodecReplacement_h
+
+#include &quot;TextCodecUTF8.h&quot;
+
+namespace WebCore {
+
+class TextCodecReplacement : public TextCodecUTF8 {
+public:
+    static std::unique_ptr&lt;TextCodec&gt; create(const TextEncoding&amp;, const void*);
+
+    TextCodecReplacement();
+
+    static void registerEncodingNames(EncodingNameRegistrar);
+    static void registerCodecs(TextCodecRegistrar);
+
+private:
+    String decode(const char*, size_t length, bool flush, bool stopOnError, bool&amp; sawError) override;
+
+    bool m_sentEOF { false };
+
+};
+
+} // namespace WebCore
+
+#endif /* TextCodecReplacement_h */
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextEncodingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextEncoding.cpp (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextEncoding.cpp        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/platform/text/TextEncoding.cpp        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -47,6 +47,9 @@
</span><span class="cx">     : m_name(atomicCanonicalTextEncodingName(name))
</span><span class="cx">     , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol())
</span><span class="cx"> {
</span><ins>+    // Aliases are valid, but not &quot;replacement&quot; itself.
+    if (m_name &amp;&amp; isReplacementEncoding(name))
+        m_name = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextEncoding::TextEncoding(const String&amp; name)
</span><span class="lines">@@ -53,6 +56,9 @@
</span><span class="cx">     : m_name(atomicCanonicalTextEncodingName(name))
</span><span class="cx">     , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol())
</span><span class="cx"> {
</span><ins>+    // Aliases are valid, but not &quot;replacement&quot; itself.
+    if (m_name &amp;&amp; isReplacementEncoding(name))
+        m_name = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String TextEncoding::decode(const char* data, size_t length, bool stopOnError, bool&amp; sawError) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextEncodingRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;TextCodecICU.h&quot;
</span><span class="cx"> #include &quot;TextCodecLatin1.h&quot;
</span><ins>+#include &quot;TextCodecReplacement.h&quot;
</ins><span class="cx"> #include &quot;TextCodecUserDefined.h&quot;
</span><span class="cx"> #include &quot;TextCodecUTF16.h&quot;
</span><span class="cx"> #include &quot;TextCodecUTF8.h&quot;
</span><span class="lines">@@ -267,6 +268,22 @@
</span><span class="cx">     return canonicalEncodingName &amp;&amp; japaneseEncodings &amp;&amp; japaneseEncodings-&gt;contains(canonicalEncodingName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool isReplacementEncoding(const char* alias)
+{
+    if (!alias)
+        return false;
+
+    if (strlen(alias) != 11)
+        return false;
+
+    return !strcasecmp(alias, &quot;replacement&quot;);
+}
+
+bool isReplacementEncoding(const String&amp; alias)
+{
+    return equalLettersIgnoringASCIICase(alias, &quot;replacement&quot;);
+}
+
</ins><span class="cx"> bool shouldShowBackslashAsCurrencySymbolIn(const char* canonicalEncodingName)
</span><span class="cx"> {
</span><span class="cx">     return canonicalEncodingName &amp;&amp; nonBackslashEncodings &amp;&amp; nonBackslashEncodings-&gt;contains(canonicalEncodingName);
</span><span class="lines">@@ -274,6 +291,9 @@
</span><span class="cx"> 
</span><span class="cx"> static void extendTextCodecMaps()
</span><span class="cx"> {
</span><ins>+    TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap);
+    TextCodecReplacement::registerCodecs(addToTextCodecMap);
+
</ins><span class="cx">     TextCodecICU::registerEncodingNames(addToTextEncodingNameMap);
</span><span class="cx">     TextCodecICU::registerCodecs(addToTextCodecMap);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextEncodingRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextEncodingRegistry.h (202598 => 202599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextEncodingRegistry.h        2016-06-29 00:47:35 UTC (rev 202598)
+++ trunk/Source/WebCore/platform/text/TextEncodingRegistry.h        2016-06-29 01:04:05 UTC (rev 202599)
</span><span class="lines">@@ -46,6 +46,8 @@
</span><span class="cx">     bool noExtendedTextEncodingNameUsed();
</span><span class="cx">     bool isJapaneseEncoding(const char* canonicalEncodingName);
</span><span class="cx">     bool shouldShowBackslashAsCurrencySymbolIn(const char* canonicalEncodingName);
</span><ins>+    bool isReplacementEncoding(const char* alias);
+    bool isReplacementEncoding(const String&amp; alias);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT String defaultTextEncodingNameForSystemLanguage();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>