Skip to content

Commit 2c843cd

Browse files
committed
trailing backslash
1 parent 88f1a43 commit 2c843cd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/org/z3950/zing/cql/CQLTermNode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ static String toCQLTerm(String str) {
242242
escaped = ch == '\\' && !escaped;
243243
sb.append(ch);
244244
}
245+
if (escaped) {
246+
// trailing backslash - escape it
247+
sb.append('\\');
248+
}
245249
if (quote) {
246250
return "\"" + sb.toString() + "\"";
247251
} else {

src/test/java/org/z3950/zing/cql/CQLTermNodeTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ public void TestTCQLTermQuoteQuote4() {
5050
}
5151

5252
@Test
53-
public void TestTCQLTermQuoteBackSlashTrail() {
54-
assertEquals("a\\", CQLTermNode.toCQLTerm("a\\"));
53+
public void TestTCQLTermQuoteBackSlashTrail1() {
54+
assertEquals("a\\\\", CQLTermNode.toCQLTerm("a\\"));
55+
}
56+
57+
@Test
58+
public void TestTCQLTermQuoteBackSlashTrail2() {
59+
assertEquals("\"a \\\\\"", CQLTermNode.toCQLTerm("a \\"));
5560
}
5661

5762
}

0 commit comments

Comments
 (0)