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

Side by Side Diff: third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp

Issue 2415373002: Loading: bulk style errors fix in core/loader (Closed)
Patch Set: Created 4 years, 2 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
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 inline void TextResourceDecoderBuilder::setupEncoding( 117 inline void TextResourceDecoderBuilder::setupEncoding(
118 TextResourceDecoder* decoder, 118 TextResourceDecoder* decoder,
119 Document* document) { 119 Document* document) {
120 LocalFrame* frame = document->frame(); 120 LocalFrame* frame = document->frame();
121 LocalFrame* parentFrame = 0; 121 LocalFrame* parentFrame = 0;
122 if (frame && frame->tree().parent() && frame->tree().parent()->isLocalFrame()) 122 if (frame && frame->tree().parent() && frame->tree().parent()->isLocalFrame())
123 parentFrame = toLocalFrame(frame->tree().parent()); 123 parentFrame = toLocalFrame(frame->tree().parent());
124 124
125 if (!m_encoding.isEmpty()) 125 if (!m_encoding.isEmpty()) {
126 decoder->setEncoding(m_encoding.getString(), 126 decoder->setEncoding(m_encoding.getString(),
127 TextResourceDecoder::EncodingFromHTTPHeader); 127 TextResourceDecoder::EncodingFromHTTPHeader);
128 }
128 129
129 // Set the hint encoding to the parent frame encoding only if the parent and 130 // Set the hint encoding to the parent frame encoding only if the parent and
130 // the current frames share the security origin. We impose this condition 131 // the current frames share the security origin. We impose this condition
131 // because somebody can make a child frameg63 containing a carefully crafted 132 // because somebody can make a child frameg63 containing a carefully crafted
132 // html/javascript in one encoding that can be mistaken for hintEncoding (or 133 // html/javascript in one encoding that can be mistaken for hintEncoding (or
133 // related encoding) by an auto detector. When interpreted in the latter, it 134 // related encoding) by an auto detector. When interpreted in the latter, it
134 // could be an attack vector. 135 // could be an attack vector.
135 // FIXME: This might be too cautious for non-7bit-encodings and we may 136 // FIXME: This might be too cautious for non-7bit-encodings and we may
136 // consider relaxing this later after testing. 137 // consider relaxing this later after testing.
137 if (frame && canReferToParentFrameEncoding(frame, parentFrame)) { 138 if (frame && canReferToParentFrameEncoding(frame, parentFrame)) {
138 if (parentFrame->document()->encodingWasDetectedHeuristically()) 139 if (parentFrame->document()->encodingWasDetectedHeuristically())
139 decoder->setHintEncoding(parentFrame->document()->encoding()); 140 decoder->setHintEncoding(parentFrame->document()->encoding());
140 141
141 if (m_encoding.isEmpty()) 142 if (m_encoding.isEmpty()) {
142 decoder->setEncoding(parentFrame->document()->encoding(), 143 decoder->setEncoding(parentFrame->document()->encoding(),
143 TextResourceDecoder::EncodingFromParentFrame); 144 TextResourceDecoder::EncodingFromParentFrame);
145 }
144 } 146 }
145 } 147 }
146 148
147 std::unique_ptr<TextResourceDecoder> TextResourceDecoderBuilder::buildFor( 149 std::unique_ptr<TextResourceDecoder> TextResourceDecoderBuilder::buildFor(
148 Document* document) { 150 Document* document) {
149 std::unique_ptr<TextResourceDecoder> decoder = 151 std::unique_ptr<TextResourceDecoder> decoder =
150 createDecoderInstance(document); 152 createDecoderInstance(document);
151 setupEncoding(decoder.get(), document); 153 setupEncoding(decoder.get(), document);
152 return decoder; 154 return decoder;
153 } 155 }
154 156
155 void TextResourceDecoderBuilder::clear() { 157 void TextResourceDecoderBuilder::clear() {
156 m_encoding = nullAtom; 158 m_encoding = nullAtom;
157 } 159 }
158 160
159 } // namespace blink 161 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698