Skip to content

Commit d09e6d6

Browse files
that additional escape logic was not obsolete...
1 parent 2755f57 commit d09e6d6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Sources/HTMLKitUtilities/HTMLKitUtilities.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public extension String {
6464
}
6565
/// Escapes all occurrences of source-breaking HTML attribute characters
6666
mutating func escapeHTMLAttributes() {
67+
self.replace("\\\"", with: """)
6768
self.replace("\"", with: """)
6869
self.replace("'", with: "&#39")
6970
}

Tests/HTMLKitTests/ElementTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ struct ElementTests {
3636

3737
string = #html(div(attributes: [.title("<p>")], "<p></p>"))
3838
#expect(string == expected_result)
39+
40+
string = #html(p("What's 9 + 10? \"21\"!"))
41+
#expect(string == "<p>What&#39s 9 + 10? &quot;21&quot;!</p>")
3942
}
4043
}
4144

0 commit comments

Comments
 (0)