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

Side by Side Diff: third_party/WebKit/Source/platform/network/FormDataEncoder.cpp

Issue 1698883005: Remove internal use of Document::defaultCharset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/platform/network/FormDataEncoder.h ('k') | no next file » | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 break; 66 break;
67 case '"': 67 case '"':
68 append(buffer, "%22"); 68 append(buffer, "%22");
69 break; 69 break;
70 default: 70 default:
71 append(buffer, c); 71 append(buffer, c);
72 } 72 }
73 } 73 }
74 } 74 }
75 75
76 WTF::TextEncoding FormDataEncoder::encodingFromAcceptCharset(const String& accep tCharset, const String& charset, const String& defaultCharset) 76 WTF::TextEncoding FormDataEncoder::encodingFromAcceptCharset(const String& accep tCharset, const WTF::TextEncoding& fallbackEncoding)
77 { 77 {
78 ASSERT(fallbackEncoding.isValid());
79
78 String normalizedAcceptCharset = acceptCharset; 80 String normalizedAcceptCharset = acceptCharset;
79 normalizedAcceptCharset.replace(',', ' '); 81 normalizedAcceptCharset.replace(',', ' ');
80 82
81 Vector<String> charsets; 83 Vector<String> charsets;
82 normalizedAcceptCharset.split(' ', charsets); 84 normalizedAcceptCharset.split(' ', charsets);
83 85
84 WTF::TextEncoding encoding; 86 for (const String& name : charsets) {
85 87 WTF::TextEncoding encoding(name);
86 Vector<String>::const_iterator end = charsets.end(); 88 if (encoding.isValid())
87 for (Vector<String>::const_iterator it = charsets.begin(); it != end; ++it) {
88 if ((encoding = WTF::TextEncoding(*it)).isValid())
89 return encoding; 89 return encoding;
90 } 90 }
91 91
92 if (charset.isEmpty()) { 92 return fallbackEncoding;
93 if (defaultCharset.isEmpty())
94 return WTF::UTF8Encoding();
95
96 return defaultCharset;
97 }
98
99 return charset;
100 } 93 }
101 94
102 Vector<char> FormDataEncoder::generateUniqueBoundaryString() 95 Vector<char> FormDataEncoder::generateUniqueBoundaryString()
103 { 96 {
104 Vector<char> boundary; 97 Vector<char> boundary;
105 98
106 // TODO(rsleevi): crbug.com/575779: Follow the spec or fix the spec. 99 // TODO(rsleevi): crbug.com/575779: Follow the spec or fix the spec.
107 // The RFC 2046 spec says the alphanumeric characters plus the 100 // The RFC 2046 spec says the alphanumeric characters plus the
108 // following characters are legal for boundaries: '()+_,-./:=? 101 // following characters are legal for boundaries: '()+_,-./:=?
109 // However the following characters, though legal, cause some sites 102 // However the following characters, though legal, cause some sites
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } else if (c == '\n' || (c == '\r' && (i + 1 >= length || string.data()[ i + 1] != '\n'))) { 211 } else if (c == '\n' || (c == '\r' && (i + 1 >= length || string.data()[ i + 1] != '\n'))) {
219 append(buffer, "%0D%0A"); 212 append(buffer, "%0D%0A");
220 } else if (c != '\r') { 213 } else if (c != '\r') {
221 append(buffer, '%'); 214 append(buffer, '%');
222 appendByteAsHex(c, buffer); 215 appendByteAsHex(c, buffer);
223 } 216 }
224 } 217 }
225 } 218 }
226 219
227 } // namespace blink 220 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/FormDataEncoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698