mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
a6c4fd98bc
Ideally, SwiftLintCore would some day only contain components that are needed to define rules. Consequently, it would be the only bundle required to import for (external) rule development.
18 lines
510 B
Swift
18 lines
510 B
Swift
extension String {
|
|
func escapedForXML() -> String {
|
|
// & needs to go first, otherwise other replacements will be replaced again
|
|
let htmlEscapes = [
|
|
("&", "&"),
|
|
("\"", """),
|
|
("'", "'"),
|
|
(">", ">"),
|
|
("<", "<"),
|
|
]
|
|
var newString = self
|
|
for (key, value) in htmlEscapes {
|
|
newString = newString.replacingOccurrences(of: key, with: value)
|
|
}
|
|
return newString
|
|
}
|
|
}
|