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

Side by Side Diff: tools/gn/xml_element_writer.cc

Issue 2813213002: Moved/renamed EscapeString from visual_studio_writer to XmlEscape in xml_element_writer. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « tools/gn/xml_element_writer.h ('k') | tools/gn/xml_element_writer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/xml_element_writer.h" 5 #include "tools/gn/xml_element_writer.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 8
9 XmlAttributes::XmlAttributes() {} 9 XmlAttributes::XmlAttributes() {}
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 opening_tag_finished_ = true; 74 opening_tag_finished_ = true;
75 75
76 if (start_new_line && one_line_) { 76 if (start_new_line && one_line_) {
77 out_ << std::endl; 77 out_ << std::endl;
78 one_line_ = false; 78 one_line_ = false;
79 } 79 }
80 } 80 }
81 81
82 return out_; 82 return out_;
83 } 83 }
84
85 std::string XmlEscape(const std::string& value) {
86 std::string result;
87 for (char c : value) {
88 switch (c) {
89 case '\n':
90 result += "&#10;";
91 break;
92 case '\r':
93 result += "&#13;";
94 break;
95 case '\t':
96 result += "&#9;";
97 break;
98 case '"':
99 result += "&quot;";
100 break;
101 case '<':
102 result += "&lt;";
103 break;
104 case '>':
105 result += "&gt;";
106 break;
107 case '&':
108 result += "&amp;";
109 break;
110 default:
111 result += c;
112 }
113 }
114 return result;
115 }
OLDNEW
« no previous file with comments | « tools/gn/xml_element_writer.h ('k') | tools/gn/xml_element_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698