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

Side by Side Diff: third_party/WebKit/Source/core/editing/serializers/MarkupFormatter.cpp

Issue 1845363003: String replaceWithLiteral should just use strlen, also rename to replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another NUL fix. Created 4 years, 8 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) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 void MarkupFormatter::appendQuotedURLAttributeValue(StringBuilder& result, const Element& element, const Attribute& attribute) 192 void MarkupFormatter::appendQuotedURLAttributeValue(StringBuilder& result, const Element& element, const Attribute& attribute)
193 { 193 {
194 ASSERT(element.isURLAttribute(attribute)); 194 ASSERT(element.isURLAttribute(attribute));
195 const String resolvedURLString = resolveURLIfNeeded(element, attribute.value ()); 195 const String resolvedURLString = resolveURLIfNeeded(element, attribute.value ());
196 UChar quoteChar = '"'; 196 UChar quoteChar = '"';
197 String strippedURLString = resolvedURLString.stripWhiteSpace(); 197 String strippedURLString = resolvedURLString.stripWhiteSpace();
198 if (protocolIsJavaScript(strippedURLString)) { 198 if (protocolIsJavaScript(strippedURLString)) {
199 // minimal escaping for javascript urls 199 // minimal escaping for javascript urls
200 if (strippedURLString.contains('&')) 200 if (strippedURLString.contains('&'))
201 strippedURLString.replaceWithLiteral('&', "&"); 201 strippedURLString.replace('&', "&");
202 202
203 if (strippedURLString.contains('"')) { 203 if (strippedURLString.contains('"')) {
204 if (strippedURLString.contains('\'')) 204 if (strippedURLString.contains('\''))
205 strippedURLString.replaceWithLiteral('"', """); 205 strippedURLString.replace('"', """);
206 else 206 else
207 quoteChar = '\''; 207 quoteChar = '\'';
208 } 208 }
209 result.append(quoteChar); 209 result.append(quoteChar);
210 result.append(strippedURLString); 210 result.append(strippedURLString);
211 result.append(quoteChar); 211 result.append(quoteChar);
212 return; 212 return;
213 } 213 }
214 214
215 // FIXME: This does not fully match other browsers. Firefox percent-escapes non-ASCII characters for innerHTML. 215 // FIXME: This does not fully match other browsers. Firefox percent-escapes non-ASCII characters for innerHTML.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 465 }
466 466
467 bool MarkupFormatter::serializeAsHTMLDocument(const Node& node) const 467 bool MarkupFormatter::serializeAsHTMLDocument(const Node& node) const
468 { 468 {
469 if (m_serializationType == SerializationType::ForcedXML) 469 if (m_serializationType == SerializationType::ForcedXML)
470 return false; 470 return false;
471 return node.document().isHTMLDocument(); 471 return node.document().isHTMLDocument();
472 } 472 }
473 473
474 } // namespace blink 474 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingStyle.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698