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

Side by Side Diff: Source/core/page/PageSerializer.cpp

Issue 19845004: Do not normalize into NFC the values of form fields (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add normalizeAndEncode() without memory safety problem Created 7 years, 5 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 | « Source/core/fileapi/BlobBuilder.cpp ('k') | Source/core/platform/network/FormDataBuilder.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 Vector<Node*> nodes; 198 Vector<Node*> nodes;
199 SerializerMarkupAccumulator accumulator(this, document, &nodes); 199 SerializerMarkupAccumulator accumulator(this, document, &nodes);
200 WTF::TextEncoding textEncoding(document->charset()); 200 WTF::TextEncoding textEncoding(document->charset());
201 CString data; 201 CString data;
202 if (!textEncoding.isValid()) { 202 if (!textEncoding.isValid()) {
203 // FIXME: iframes used as images trigger this. We should deal with them correctly. 203 // FIXME: iframes used as images trigger this. We should deal with them correctly.
204 return; 204 return;
205 } 205 }
206 String text = accumulator.serializeNodes(document->documentElement(), Includ eNode); 206 String text = accumulator.serializeNodes(document->documentElement(), Includ eNode);
207 CString frameHTML = textEncoding.encode(text, WTF::EntitiesForUnencodables); 207 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn encodables);
208 m_resources->append(SerializedResource(url, document->suggestedMIMEType(), S haredBuffer::create(frameHTML.data(), frameHTML.length()))); 208 m_resources->append(SerializedResource(url, document->suggestedMIMEType(), S haredBuffer::create(frameHTML.data(), frameHTML.length())));
209 m_resourceURLs.add(url); 209 m_resourceURLs.add(url);
210 210
211 for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++it er) { 211 for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++it er) {
212 Node* node = *iter; 212 Node* node = *iter;
213 if (!node->isElementNode()) 213 if (!node->isElementNode())
214 continue; 214 continue;
215 215
216 Element* element = toElement(node); 216 Element* element = toElement(node);
217 // We have to process in-line style as it might contain some resources ( typically background images). 217 // We have to process in-line style as it might contain some resources ( typically background images).
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // be retrieved from the CSSFontFaceRule object. 265 // be retrieved from the CSSFontFaceRule object.
266 } else if (rule->type() == CSSRule::STYLE_RULE) 266 } else if (rule->type() == CSSRule::STYLE_RULE)
267 retrieveResourcesForRule(static_cast<CSSStyleRule*>(rule)->styleRule (), document); 267 retrieveResourcesForRule(static_cast<CSSStyleRule*>(rule)->styleRule (), document);
268 } 268 }
269 269
270 if (url.isValid() && !m_resourceURLs.contains(url)) { 270 if (url.isValid() && !m_resourceURLs.contains(url)) {
271 // FIXME: We should check whether a charset has been specified and if no ne was found add one. 271 // FIXME: We should check whether a charset has been specified and if no ne was found add one.
272 WTF::TextEncoding textEncoding(styleSheet->contents()->charset()); 272 WTF::TextEncoding textEncoding(styleSheet->contents()->charset());
273 ASSERT(textEncoding.isValid()); 273 ASSERT(textEncoding.isValid());
274 String textString = cssText.toString(); 274 String textString = cssText.toString();
275 CString text = textEncoding.encode(textString, WTF::EntitiesForUnencodab les); 275 CString text = textEncoding.normalizeAndEncode(textString, WTF::Entities ForUnencodables);
276 m_resources->append(SerializedResource(url, String("text/css"), SharedBu ffer::create(text.data(), text.length()))); 276 m_resources->append(SerializedResource(url, String("text/css"), SharedBu ffer::create(text.data(), text.length())));
277 m_resourceURLs.add(url); 277 m_resourceURLs.add(url);
278 } 278 }
279 } 279 }
280 280
281 void PageSerializer::addImageToResources(CachedImage* image, RenderObject* image Renderer, const KURL& url) 281 void PageSerializer::addImageToResources(CachedImage* image, RenderObject* image Renderer, const KURL& url)
282 { 282 {
283 if (!url.isValid() || m_resourceURLs.contains(url)) 283 if (!url.isValid() || m_resourceURLs.contains(url))
284 return; 284 return;
285 285
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (iter != m_blankFrameURLs.end()) 336 if (iter != m_blankFrameURLs.end())
337 return iter->value; 337 return iter->value;
338 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); 338 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++);
339 KURL fakeURL(ParsedURLString, url); 339 KURL fakeURL(ParsedURLString, url);
340 m_blankFrameURLs.add(frame, fakeURL); 340 m_blankFrameURLs.add(frame, fakeURL);
341 341
342 return fakeURL; 342 return fakeURL;
343 } 343 }
344 344
345 } 345 }
OLDNEW
« no previous file with comments | « Source/core/fileapi/BlobBuilder.cpp ('k') | Source/core/platform/network/FormDataBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698