OLD | NEW |
---|---|
1 /* | 1 /* |
2 Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. | 3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. |
4 Copyright (C) 2005, 2006, 2007 Alexey Proskuryakov (ap@nypop.com) | 4 Copyright (C) 2005, 2006, 2007 Alexey Proskuryakov (ap@nypop.com) |
5 | 5 |
6 This library is free software; you can redistribute it and/or | 6 This library is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
8 License as published by the Free Software Foundation; either | 8 License as published by the Free Software Foundation; either |
9 version 2 of the License, or (at your option) any later version. | 9 version 2 of the License, or (at your option) any later version. |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 TextResourceDecoder::~TextResourceDecoder() | 130 TextResourceDecoder::~TextResourceDecoder() |
131 { | 131 { |
132 } | 132 } |
133 | 133 |
134 void TextResourceDecoder::setEncoding(const WTF::TextEncoding& encoding, Encodin gSource source) | 134 void TextResourceDecoder::setEncoding(const WTF::TextEncoding& encoding, Encodin gSource source) |
135 { | 135 { |
136 // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings). | 136 // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings). |
137 if (!encoding.isValid()) | 137 if (!encoding.isValid()) |
138 return; | 138 return; |
139 | 139 |
140 // Default encoding for XML content should remain as UTF-8 even if the autod etection comes into play | |
Jinsuk Kim
2016/09/05 10:08:50
This change was made to make following XML tests p
tkent
2016/09/05 23:53:45
Why did they fail? Did the other part of this CL
| |
141 // to detect it as Latin-1. | |
142 if (m_contentType == XMLContent && source == EncodingFromContentSniffing && encoding == Latin1Encoding()) | |
143 return; | |
144 | |
140 // When encoding comes from meta tag (i.e. it cannot be XML files sent via X HR), | 145 // When encoding comes from meta tag (i.e. it cannot be XML files sent via X HR), |
141 // treat x-user-defined as windows-1252 (bug 18270) | 146 // treat x-user-defined as windows-1252 (bug 18270). |
142 if (source == EncodingFromMetaTag && !strcasecmp(encoding.name(), "x-user-de fined")) | 147 if (source == EncodingFromMetaTag && !strcasecmp(encoding.name(), "x-user-de fined")) |
143 m_encoding = "windows-1252"; | 148 m_encoding = "windows-1252"; |
144 else if (source == EncodingFromMetaTag || source == EncodingFromXMLHeader || source == EncodingFromCSSCharset) | 149 else if (source == EncodingFromMetaTag || source == EncodingFromXMLHeader || source == EncodingFromCSSCharset) |
145 m_encoding = encoding.closestByteBasedEquivalent(); | 150 m_encoding = encoding.closestByteBasedEquivalent(); |
146 else | 151 else |
147 m_encoding = encoding; | 152 m_encoding = encoding; |
148 | 153 |
149 m_codec.reset(); | 154 m_codec.reset(); |
150 m_source = source; | 155 m_source = source; |
151 } | 156 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 m_codec = newTextCodec(m_encoding); | 449 m_codec = newTextCodec(m_encoding); |
445 | 450 |
446 String result = m_codec->decode(m_buffer.data(), m_buffer.size(), FetchEOF, m_contentType == XMLContent && !m_useLenientXMLDecoding, m_sawError); | 451 String result = m_codec->decode(m_buffer.data(), m_buffer.size(), FetchEOF, m_contentType == XMLContent && !m_useLenientXMLDecoding, m_sawError); |
447 m_buffer.clear(); | 452 m_buffer.clear(); |
448 m_codec.reset(); | 453 m_codec.reset(); |
449 m_checkedForBOM = false; // Skip BOM again when re-decoding. | 454 m_checkedForBOM = false; // Skip BOM again when re-decoding. |
450 return result; | 455 return result; |
451 } | 456 } |
452 | 457 |
453 } // namespace blink | 458 } // namespace blink |
OLD | NEW |