OLD | NEW |
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 140 } |
141 | 141 |
142 inline void TextResourceDecoderBuilder::setupEncoding(TextResourceDecoder* decod
er, Document* document) | 142 inline void TextResourceDecoderBuilder::setupEncoding(TextResourceDecoder* decod
er, Document* document) |
143 { | 143 { |
144 LocalFrame* frame = document->frame(); | 144 LocalFrame* frame = document->frame(); |
145 LocalFrame* parentFrame = 0; | 145 LocalFrame* parentFrame = 0; |
146 if (frame && frame->tree().parent() && frame->tree().parent()->isLocalFrame(
)) | 146 if (frame && frame->tree().parent() && frame->tree().parent()->isLocalFrame(
)) |
147 parentFrame = toLocalFrame(frame->tree().parent()); | 147 parentFrame = toLocalFrame(frame->tree().parent()); |
148 | 148 |
149 if (!m_encoding.isEmpty()) | 149 if (!m_encoding.isEmpty()) |
150 decoder->setEncoding(m_encoding.string(), TextResourceDecoder::EncodingF
romHTTPHeader); | 150 decoder->setEncoding(m_encoding.getString(), TextResourceDecoder::Encodi
ngFromHTTPHeader); |
151 | 151 |
152 // Set the hint encoding to the parent frame encoding only if | 152 // Set the hint encoding to the parent frame encoding only if |
153 // the parent and the current frames share the security origin. | 153 // the parent and the current frames share the security origin. |
154 // We impose this condition because somebody can make a child frameg63 | 154 // We impose this condition because somebody can make a child frameg63 |
155 // containing a carefully crafted html/javascript in one encoding | 155 // containing a carefully crafted html/javascript in one encoding |
156 // that can be mistaken for hintEncoding (or related encoding) by | 156 // that can be mistaken for hintEncoding (or related encoding) by |
157 // an auto detector. When interpreted in the latter, it could be | 157 // an auto detector. When interpreted in the latter, it could be |
158 // an attack vector. | 158 // an attack vector. |
159 // FIXME: This might be too cautious for non-7bit-encodings and | 159 // FIXME: This might be too cautious for non-7bit-encodings and |
160 // we may consider relaxing this later after testing. | 160 // we may consider relaxing this later after testing. |
(...skipping 12 matching lines...) Expand all Loading... |
173 setupEncoding(decoder.get(), document); | 173 setupEncoding(decoder.get(), document); |
174 return decoder.release(); | 174 return decoder.release(); |
175 } | 175 } |
176 | 176 |
177 void TextResourceDecoderBuilder::clear() | 177 void TextResourceDecoderBuilder::clear() |
178 { | 178 { |
179 m_encoding = nullAtom; | 179 m_encoding = nullAtom; |
180 } | 180 } |
181 | 181 |
182 } // namespace blink | 182 } // namespace blink |
OLD | NEW |