Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Issue 1470893002: [Fetch] Always use utf-8 for decoding in text() (Closed)

Created:
5 years, 1 month ago by hiroshige
Modified:
5 years ago
CC:
chromium-reviews, blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Fetch] Always use utf-8 for decoding in text() In the spec, Response.text() should run utf-8 decode [1][2], i.e. always use utf-8. But in the implementation, TextResourceDecoder used by Response.text() decodes the input as utf-16/32 if it contains utf-16/32 BOMs. This CL - Adds TextResourceDecoder::createAlwaysUseUTF8ForText() and AlwaysUseUTF8ForText that corresponds to utf-8 decode in the spec [2]. - Fixes Response.text() by using CheckForOnlyUTF8BOM in FetchDataLoaderAsString. - Adds layout tests for Fetch API and XHRs (but doesn't change the behavior of XHRs). [1] https://fetch.spec.whatwg.org/#concept-body-package-data [2] https://encoding.spec.whatwg.org/#utf-8-decode BUG=557510 Committed: https://crrev.com/2198aba1db661a195eb6f191274c1595c3bc6867 Cr-Commit-Position: refs/heads/master@{#364978}

Patch Set 1 #

Patch Set 2 : Update tests. #

Patch Set 3 : Added fix. #

Patch Set 4 : Update comments. #

Patch Set 5 : Use PHP to avoid BOMs in raw binary files. #

Patch Set 6 : Without fix. #

Patch Set 7 : Add fixes. #

Total comments: 2

Patch Set 8 : #

Total comments: 1

Patch Set 9 : Remove numerical enum value comparison. #

Total comments: 6

Patch Set 10 : Reflect comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+148 lines, -21 lines) Patch
A third_party/WebKit/LayoutTests/http/tests/fetch/resources/bom-utf-16be.php View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/fetch/resources/bom-utf-16le.php View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/fetch/resources/bom-utf-8.php View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js View 1 2 3 4 5 6 7 8 9 1 chunk +30 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom.html View 1 2 3 4 1 chunk +36 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom-expected.txt View 1 2 3 4 1 chunk +12 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/resources/bom-utf-16be.php View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/resources/bom-utf-16le.php View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/resources/bom-utf-8.php View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h View 1 2 3 4 5 6 7 8 9 3 chunks +30 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp View 1 2 3 4 5 6 7 8 9 4 chunks +21 lines, -17 lines 0 comments Download
M third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 51 (26 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/1
5 years, 1 month ago (2015-11-23 11:25:50 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/144517)
5 years, 1 month ago (2015-11-23 12:25:35 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/40001
5 years, 1 month ago (2015-11-23 12:42:27 UTC) #6
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/60001
5 years, 1 month ago (2015-11-23 13:19:56 UTC) #9
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/100001
5 years, 1 month ago (2015-11-23 14:32:33 UTC) #12
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/120001
5 years, 1 month ago (2015-11-23 14:34:10 UTC) #14
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years, 1 month ago (2015-11-23 15:40:54 UTC) #16
hiroshige
PTAL.
5 years, 1 month ago (2015-11-23 18:33:39 UTC) #18
yhirano
https://codereview.chromium.org/1470893002/diff/120001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp File third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp (right): https://codereview.chromium.org/1470893002/diff/120001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp#newcode197 third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp:197: // We let it override even a user-chosen encoding. ...
5 years, 1 month ago (2015-11-24 02:06:40 UTC) #19
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/130001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/130001
5 years ago (2015-11-30 08:50:25 UTC) #21
hiroshige
https://codereview.chromium.org/1470893002/diff/120001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp File third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp (right): https://codereview.chromium.org/1470893002/diff/120001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp#newcode197 third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp:197: // We let it override even a user-chosen encoding. ...
5 years ago (2015-11-30 09:50:01 UTC) #22
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-11-30 10:04:23 UTC) #24
yhirano
lgtm https://codereview.chromium.org/1470893002/diff/130001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp File third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp (right): https://codereview.chromium.org/1470893002/diff/130001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp#newcode214 third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp:214: if (m_encodingDetectionOption <= UseContentAndBOMBasedDetection && c1 == 0xFF ...
5 years ago (2015-12-02 08:28:30 UTC) #25
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/150001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/150001
5 years ago (2015-12-03 07:25:48 UTC) #27
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-03 08:36:49 UTC) #29
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/150001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/150001
5 years ago (2015-12-10 06:20:19 UTC) #33
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-10 08:38:22 UTC) #35
hiroshige
kouhei@, could you take a look as a core/html/parser OWNER?
5 years ago (2015-12-11 04:57:11 UTC) #37
kouhei (in TOK)
https://codereview.chromium.org/1470893002/diff/150001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp File third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp (right): https://codereview.chromium.org/1470893002/diff/150001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp#newcode128 third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp:128: ASSERT(!(m_encodingDetectionOption == AlwaysUseUTF8ForText && (m_contentType != PlainTextContent || m_encoding ...
5 years ago (2015-12-14 02:00:22 UTC) #38
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/170001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/170001
5 years ago (2015-12-14 05:38:56 UTC) #40
hiroshige
Also updated CL description. https://codereview.chromium.org/1470893002/diff/150001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp File third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp (right): https://codereview.chromium.org/1470893002/diff/150001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp#newcode128 third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp:128: ASSERT(!(m_encodingDetectionOption == AlwaysUseUTF8ForText && (m_contentType ...
5 years ago (2015-12-14 05:44:03 UTC) #42
kouhei (in TOK)
lgtm > https://codereview.chromium.org/1470893002/diff/150001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h > File third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h (right): > > https://codereview.chromium.org/1470893002/diff/150001/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h#newcode49 > third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h:49: static > PassOwnPtr<TextResourceDecoder> ...
5 years ago (2015-12-14 05:47:45 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1470893002/170001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1470893002/170001
5 years ago (2015-12-14 06:35:26 UTC) #47
commit-bot: I haz the power
Committed patchset #10 (id:170001)
5 years ago (2015-12-14 07:17:36 UTC) #49
commit-bot: I haz the power
5 years ago (2015-12-14 07:18:23 UTC) #51
Message was sent while issue was closed.
Patchset 10 (id:??) landed as
https://crrev.com/2198aba1db661a195eb6f191274c1595c3bc6867
Cr-Commit-Position: refs/heads/master@{#364978}

Powered by Google App Engine
This is Rietveld 408576698