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

Issue 145973021: Implement "replacement" text encoding. (Closed)

Created:
6 years, 10 months ago by jsbell
Modified:
6 years, 7 months ago
CC:
blink-reviews, yurys+blink_chromium.org, loislo+blink_chromium.org, adamk+blink_chromium.org, Inactive, abarth-chromium
Visibility:
Public.

Description

Implement "replacement" text encoding. The WHATWG Encoding Standard redefines certain legacy encodings as that are only used as XSS attack vectors as aliases for an abstract "replacement" encoding. * Decode (of resources) terminates with a single U+FFFD. * Encode (e.g. for form submissions) is treated as UTF-8. * The JS TextDecoder API throws if the aliases are used. * The "replacement" string itself isn't assigned any meaning. The last note can violate assumptions that a codec's name is always an alias for itself, so it is enforced at the encoding lookup-by-name function and script entry points. BUG=277037 R=jshin@chromium.org,eseidel@chromium.org

Patch Set 1 #

Patch Set 2 : Verify replacement name #

Total comments: 1

Patch Set 3 : Rebased, sync to spec #

Patch Set 4 : Add explicit replacement test #

Patch Set 5 : Replacement codec should emit U+FFFD #

Total comments: 4

Patch Set 6 : Redo registration #

Patch Set 7 : Make hz-gb-2312 a label for replacement #

Patch Set 8 : Rebase tests w/ hz-gb-2312 gone #

Patch Set 9 : Revert encoding name storage changes - unneeded #

Patch Set 10 : Make codec registration 'normal' #

Patch Set 11 : Reworked tests, still WIP #

Unified diffs Side-by-side diffs Delta from patch set Stats (+624 lines, -34 lines) Patch
M LayoutTests/fast/encoding/api/ascii-supersets.html View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -1 line 0 comments Download
M LayoutTests/fast/encoding/api/ascii-supersets-expected.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -2 lines 0 comments Download
M LayoutTests/fast/encoding/api/encoding-labels.html View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -1 line 0 comments Download
M LayoutTests/fast/encoding/api/encoding-labels-expected.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -3 lines 0 comments Download
M LayoutTests/fast/encoding/api/legacy-encode-expected.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -2 lines 0 comments Download
A LayoutTests/fast/encoding/api/replacement-encoding.html View 1 2 3 4 5 6 7 8 9 10 1 chunk +26 lines, -0 lines 0 comments Download
A LayoutTests/fast/encoding/api/replacement-encoding-expected.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +9 lines, -0 lines 0 comments Download
A LayoutTests/fast/encoding/api/resources/encodings.json View 7 8 9 10 1 chunk +453 lines, -0 lines 0 comments Download
M LayoutTests/fast/encoding/api/resources/shared.js View 1 2 3 4 5 6 7 8 9 10 4 chunks +21 lines, -17 lines 0 comments Download
M LayoutTests/fast/encoding/char-decoding.html View 1 2 3 4 3 chunks +10 lines, -4 lines 0 comments Download
M LayoutTests/fast/encoding/char-decoding-expected.txt View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M LayoutTests/fast/encoding/char-encoding.html View 1 chunk +6 lines, -0 lines 0 comments Download
M LayoutTests/fast/encoding/char-encoding-expected.txt View 1 chunk +4 lines, -0 lines 0 comments Download
A + LayoutTests/fast/encoding/charset-replacement.html View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
A + LayoutTests/fast/encoding/charset-replacement-expected.png View Binary file 0 comments Download
A + LayoutTests/fast/encoding/charset-replacement-expected.txt View 1 2 3 0 chunks +-1 lines, --1 lines 0 comments Download
M Source/modules/encoding/TextDecoder.cpp View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
A Source/wtf/text/TextCodecReplacement.h View 1 2 3 4 6 7 8 9 1 chunk +28 lines, -0 lines 0 comments Download
A Source/wtf/text/TextCodecReplacement.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +48 lines, -0 lines 0 comments Download
M Source/wtf/text/TextCodecUTF8.h View 1 2 1 chunk +4 lines, -2 lines 0 comments Download
M Source/wtf/text/TextEncodingRegistry.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -0 lines 0 comments Download
M Source/wtf/wtf.gypi View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 33 (0 generated)
jungshik at Google
Should I start reviewing the CL or wait? I was a bit confused because the ...
6 years, 10 months ago (2014-02-21 22:27:40 UTC) #1
jsbell
On 2014/02/21 22:27:40, Jungshik Shin wrote: > Should I start reviewing the CL or wait? ...
6 years, 10 months ago (2014-02-21 22:29:11 UTC) #2
jsbell
https://codereview.chromium.org/145973021/diff/20001/Source/wtf/text/TextEncodingRegistry.cpp File Source/wtf/text/TextEncodingRegistry.cpp (right): https://codereview.chromium.org/145973021/diff/20001/Source/wtf/text/TextEncodingRegistry.cpp#newcode227 Source/wtf/text/TextEncodingRegistry.cpp:227: textEncodingNameMap->remove("replacement"); This seems like a hack, but so far ...
6 years, 10 months ago (2014-02-21 22:35:55 UTC) #3
jsbell
jshin@ - I think this is ready for a look now. Can you do an ...
6 years, 9 months ago (2014-03-10 18:32:57 UTC) #4
jsbell
On 2014/03/10 18:32:57, jsbell wrote: > jshin@ - I think this is ready for a ...
6 years, 9 months ago (2014-03-14 20:28:29 UTC) #5
jsbell
On 2014/03/14 20:28:29, jsbell wrote: > On 2014/03/10 18:32:57, jsbell wrote: > > jshin@ - ...
6 years, 9 months ago (2014-03-14 20:34:28 UTC) #6
jsbell
On 2014/03/14 20:34:28, jsbell wrote: > New patch uploaded, but I have mail out to ...
6 years, 9 months ago (2014-03-17 16:02:56 UTC) #7
jungshik at Google
On 2014/03/17 16:02:56, jsbell wrote: > On 2014/03/14 20:34:28, jsbell wrote: > > New patch ...
6 years, 8 months ago (2014-04-01 21:39:48 UTC) #8
jsbell
eseidel@ - can you take a look at the wtf/text changes? I'm not entirely thrilled ...
6 years, 8 months ago (2014-04-01 21:50:13 UTC) #9
eseidel
I'm confused as to what this is trying to do and why it needs to ...
6 years, 8 months ago (2014-04-01 22:14:42 UTC) #10
jsbell
On 2014/04/01 22:14:42, eseidel wrote: > I'm confused as to what this is trying to ...
6 years, 8 months ago (2014-04-01 22:41:58 UTC) #11
eseidel
I think we should look at encoding numbers. Last ones I saw didn't even see ...
6 years, 8 months ago (2014-04-01 23:09:08 UTC) #12
eseidel
We should remove these and any other possibly dangerous low-usage encodings. https://codereview.chromium.org/145973021/diff/130001/Source/wtf/text/TextCodecReplacement.cpp File Source/wtf/text/TextCodecReplacement.cpp (right): ...
6 years, 8 months ago (2014-04-01 23:12:16 UTC) #13
jsbell
On 2014/04/01 23:12:16, eseidel wrote: > We should remove these and any other possibly dangerous ...
6 years, 8 months ago (2014-04-01 23:26:43 UTC) #14
jungshik at Google
On 2014/04/01 23:26:43, jsbell wrote: > On 2014/04/01 23:12:16, eseidel wrote: > > We should ...
6 years, 8 months ago (2014-04-02 00:36:40 UTC) #15
jungshik at Google
+tsepez for securtiy perspective.
6 years, 8 months ago (2014-04-02 00:37:05 UTC) #16
eseidel
I'm confused. Why can't we just register a decoder for these 4 types w/o all ...
6 years, 8 months ago (2014-04-02 04:47:02 UTC) #17
eseidel
We should just completely remove support for these encodings in whatever is deemed a secure ...
6 years, 8 months ago (2014-04-02 04:48:27 UTC) #18
jungshik at Google
On 2014/04/02 04:48:27, eseidel wrote: > We should just completely remove support for these encodings ...
6 years, 8 months ago (2014-04-02 10:47:15 UTC) #19
jungshik at Google
> What do we do for the "foo-bar" encoding? We just treat > it as ...
6 years, 8 months ago (2014-04-02 10:50:39 UTC) #20
jungshik at Google
I read http://crbug.com/21354. What I did for ISO-2022-CN(-Ext) is that turn every 'character' (that is ...
6 years, 8 months ago (2014-04-02 17:03:38 UTC) #21
jungshik at Google
@jsbell, what does the encoding spec say about 'charset=foobar' (unrecognized labels)? Apparently, if an encoding ...
6 years, 8 months ago (2014-04-02 17:52:26 UTC) #22
eseidel
In summary, I think we should add the minimum amount of complexity necessary to remove ...
6 years, 8 months ago (2014-04-02 18:00:15 UTC) #23
jsbell
On 2014/04/02 17:52:26, Jungshik Shin wrote: > @jsbell, what does the encoding spec say about ...
6 years, 8 months ago (2014-04-02 18:07:37 UTC) #24
jungshik at Google
On 2014/04/02 18:07:37, jsbell wrote: > On 2014/04/02 17:52:26, Jungshik Shin wrote: > For a ...
6 years, 8 months ago (2014-04-02 19:07:03 UTC) #25
jsbell
Sorry about the long cycle time on this CL... On 2014/04/02 04:47:02, eseidel wrote: > ...
6 years, 8 months ago (2014-04-14 21:28:52 UTC) #26
jsbell
eseidel@, jshin@ - ping? See #msg26
6 years, 8 months ago (2014-04-21 17:11:40 UTC) #27
jungshik at Google
On 2014/04/14 21:28:52, jsbell wrote: > Sorry about the long cycle time on this CL... ...
6 years, 8 months ago (2014-04-21 22:36:03 UTC) #28
jungshik at Google
On 2014/04/21 17:11:40, jsbell wrote: > eseidel@, jshin@ - ping? See #msg26 Thank you and ...
6 years, 8 months ago (2014-04-21 22:46:33 UTC) #29
jsbell
On 2014/04/21 22:46:33, Jungshik Shin wrote: > On 2014/04/21 17:11:40, jsbell wrote: > > eseidel@, ...
6 years, 8 months ago (2014-04-24 20:53:05 UTC) #30
jsbell
FYI, this patch still needs rethinking on my part. The assumption (and ASSERTs) that an ...
6 years, 7 months ago (2014-05-01 16:15:44 UTC) #31
eseidel
sgtm.
6 years, 7 months ago (2014-05-01 17:28:35 UTC) #32
jsbell
6 years, 7 months ago (2014-05-02 18:24:51 UTC) #33
Message was sent while issue was closed.
Closing this. I've got a set of 3 CLs lined up:

1: script API impl simplification and test cleanup -
https://codereview.chromium.org/269593009 - no wtf changes

2: Introduce TextCodecReplacement and tests - no script API changes

3: Block use of 'replacement" alias from content/script, add tests

Powered by Google App Engine
This is Rietveld 408576698