File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ internal fun Appendable.escapeAppend(value: CharSequence) {
191
191
while (currentIndex < value.length) {
192
192
val code = value[currentIndex].code
193
193
194
- if (code == ' \\ ' .code) {
194
+ if (code == ' \\ ' .code && currentIndex + 1 < value.length && value[currentIndex + 1 ] == ' & ' ) {
195
195
append(value.substring(lastIndex, currentIndex))
196
196
check(currentIndex + 1 < value.length) { " String must not end with '\\ '." }
197
197
append(value[currentIndex + 1 ])
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class EscapeAppendTest {
7
7
@Test
8
8
fun testAppendEscaped () {
9
9
assertEquals(" &" , escape(" \\ &" ))
10
- assertEquals(" a" , escape(" \\ a" ))
10
+ assertEquals(" \\ a" , escape(" \\ a" ))
11
11
}
12
12
13
13
@Test
@@ -25,6 +25,16 @@ class EscapeAppendTest {
25
25
assertEquals(" &&" , escape(" \\ &&" ))
26
26
assertEquals(" &" , escape(" \\ &" ))
27
27
}
28
+
29
+ @Test
30
+ fun testEscapeSlash () {
31
+ assertEquals(" \\ " , escape(" \\ " ))
32
+ }
33
+
34
+ @Test
35
+ fun testEscapeUnicode () {
36
+ assertEquals(" \\ u003d" , escape(" \\ u003d" ))
37
+ }
28
38
}
29
39
30
40
private fun escape (string : String ): String = buildString {
You can’t perform that action at this time.
0 commit comments