OLD | NEW |
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 Loading... |
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 += " "; |
| 91 break; |
| 92 case '\r': |
| 93 result += " "; |
| 94 break; |
| 95 case '\t': |
| 96 result += "	"; |
| 97 break; |
| 98 case '"': |
| 99 result += """; |
| 100 break; |
| 101 case '<': |
| 102 result += "<"; |
| 103 break; |
| 104 case '>': |
| 105 result += ">"; |
| 106 break; |
| 107 case '&': |
| 108 result += "&"; |
| 109 break; |
| 110 default: |
| 111 result += c; |
| 112 } |
| 113 } |
| 114 return result; |
| 115 } |
OLD | NEW |