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

Side by Side Diff: Source/modules/encoding/TextDecoder.cpp

Issue 1071283004: Encoding API: ignore leading/trailing whitespace in labels (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/encoding/Encoding.cpp ('k') | Source/modules/encoding/TextEncoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/encoding/TextDecoder.h" 32 #include "modules/encoding/TextDecoder.h"
33 33
34 #include "bindings/core/v8/ExceptionState.h" 34 #include "bindings/core/v8/ExceptionState.h"
35 #include "core/dom/DOMArrayBuffer.h" 35 #include "core/dom/DOMArrayBuffer.h"
36 #include "core/dom/DOMArrayBufferView.h" 36 #include "core/dom/DOMArrayBufferView.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "modules/encoding/Encoding.h"
38 #include "wtf/StringExtras.h" 39 #include "wtf/StringExtras.h"
39 #include "wtf/text/TextEncodingRegistry.h" 40 #include "wtf/text/TextEncodingRegistry.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 TextDecoder* TextDecoder::create(const String& label, const TextDecoderOptions& options, ExceptionState& exceptionState) 44 TextDecoder* TextDecoder::create(const String& label, const TextDecoderOptions& options, ExceptionState& exceptionState)
44 { 45 {
45 WTF::TextEncoding encoding(label); 46 WTF::TextEncoding encoding(label.stripWhiteSpace(&Encoding::isASCIIWhiteSpac e));
46 // The replacement encoding is not valid, but the Encoding API also 47 // The replacement encoding is not valid, but the Encoding API also
47 // rejects aliases of the replacement encoding. 48 // rejects aliases of the replacement encoding.
48 if (!encoding.isValid() || !strcasecmp(encoding.name(), "replacement")) { 49 if (!encoding.isValid() || !strcasecmp(encoding.name(), "replacement")) {
49 exceptionState.throwRangeError("The encoding label provided ('" + label + "') is invalid."); 50 exceptionState.throwRangeError("The encoding label provided ('" + label + "') is invalid.");
50 return 0; 51 return 0;
51 } 52 }
52 53
53 return new TextDecoder(encoding, options.fatal(), options.ignoreBOM()); 54 return new TextDecoder(encoding, options.fatal(), options.ignoreBOM());
54 } 55 }
55 56
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return s; 117 return s;
117 } 118 }
118 119
119 String TextDecoder::decode(ExceptionState& exceptionState) 120 String TextDecoder::decode(ExceptionState& exceptionState)
120 { 121 {
121 TextDecodeOptions options; 122 TextDecodeOptions options;
122 return decode(nullptr, 0, options, exceptionState); 123 return decode(nullptr, 0, options, exceptionState);
123 } 124 }
124 125
125 } // namespace blink 126 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/encoding/Encoding.cpp ('k') | Source/modules/encoding/TextEncoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698