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

Side by Side Diff: Source/core/editing/MarkupAccumulator.cpp

Issue 26193002: XMLSerializer escapes < > & correctly inside <script> and <style> tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed feedback. Created 7 years, 1 month 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 | « LayoutTests/fast/dom/XMLSerializer-entities-expected.txt ('k') | no next file » | 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) 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 result.append('='); 297 result.append('=');
298 result.append('"'); 298 result.append('"');
299 appendAttributeValue(result, namespaceURI, false); 299 appendAttributeValue(result, namespaceURI, false);
300 result.append('"'); 300 result.append('"');
301 } 301 }
302 } 302 }
303 303
304 EntityMask MarkupAccumulator::entityMaskForText(Text* text) const 304 EntityMask MarkupAccumulator::entityMaskForText(Text* text) const
305 { 305 {
306 if (!text->document().isHTMLDocument())
307 return EntityMaskInPCDATA;
308
306 const QualifiedName* parentName = 0; 309 const QualifiedName* parentName = 0;
307 if (text->parentElement()) 310 if (text->parentElement())
308 parentName = &(text->parentElement())->tagQName(); 311 parentName = &(text->parentElement())->tagQName();
309 312
310 if (parentName && (*parentName == scriptTag || *parentName == styleTag || *p arentName == xmpTag)) 313 if (parentName && (*parentName == scriptTag || *parentName == styleTag || *p arentName == xmpTag))
311 return EntityMaskInCDATA; 314 return EntityMaskInCDATA;
312 315 return EntityMaskInHTMLPCDATA;
313 return text->document().isHTMLDocument() ? EntityMaskInHTMLPCDATA : EntityMa skInPCDATA;
314 } 316 }
315 317
316 void MarkupAccumulator::appendText(StringBuilder& result, Text* text) 318 void MarkupAccumulator::appendText(StringBuilder& result, Text* text)
317 { 319 {
318 appendNodeValue(result, text, m_range, entityMaskForText(text)); 320 appendNodeValue(result, text, m_range, entityMaskForText(text));
319 } 321 }
320 322
321 void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme nt) 323 void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme nt)
322 { 324 {
323 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly ot her callers) should raise an exception if it includes "-->". 325 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly ot her callers) should raise an exception if it includes "-->".
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes () && elementCannotHaveEndTag(node))) 548 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes () && elementCannotHaveEndTag(node)))
547 return; 549 return;
548 550
549 result.append('<'); 551 result.append('<');
550 result.append('/'); 552 result.append('/');
551 result.append(toElement(node)->nodeNamePreservingCase()); 553 result.append(toElement(node)->nodeNamePreservingCase());
552 result.append('>'); 554 result.append('>');
553 } 555 }
554 556
555 } 557 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/XMLSerializer-entities-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698