aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-10-21 13:25:55 +0200
committerjonmv <venstad@gmail.com>2022-10-21 13:25:55 +0200
commit60149c673b244d27f0c7af00f1015479ed611cb0 (patch)
tree0d7240853c045ca46f8ed851273e8c7f7e82a4a4 /client/src
parent56e1715bb9d40ed751c4e377a3d1ee47aab84380 (diff)
Surely, escapeJava cannot be right--use JSON escaping instead
Diffstat (limited to 'client/src')
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/Field.java8
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/GeoLocation.java4
2 files changed, 4 insertions, 8 deletions
diff --git a/client/src/main/java/ai/vespa/client/dsl/Field.java b/client/src/main/java/ai/vespa/client/dsl/Field.java
index f166101a854..6d199ead2b8 100644
--- a/client/src/main/java/ai/vespa/client/dsl/Field.java
+++ b/client/src/main/java/ai/vespa/client/dsl/Field.java
@@ -1,8 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.client.dsl;
-import org.apache.commons.text.StringEscapeUtils;
-
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -578,7 +576,7 @@ public class Field extends QueryChain {
}
private Query common(String relation, Annotation annotation, String value) {
- Object v = "\"" + StringEscapeUtils.escapeJava(value) + "\"";
+ Object v = Q.toJson(value);
return common(relation, annotation, v, values.toArray());
}
@@ -587,8 +585,8 @@ public class Field extends QueryChain {
}
private Query common(String relation, Annotation annotation, String value, String[] others) {
- Object v = "\"" + StringEscapeUtils.escapeJava(value) + "\"";
- Object[] o = Stream.of(others).map(s -> "\"" + StringEscapeUtils.escapeJava(s) + "\"").toArray();
+ Object v = Q.toJson(value);
+ Object[] o = Stream.of(others).map(Q::toJson).toArray();
return common(relation, annotation, v, o);
}
diff --git a/client/src/main/java/ai/vespa/client/dsl/GeoLocation.java b/client/src/main/java/ai/vespa/client/dsl/GeoLocation.java
index 8ccb2e69749..bdf2ccc15c5 100644
--- a/client/src/main/java/ai/vespa/client/dsl/GeoLocation.java
+++ b/client/src/main/java/ai/vespa/client/dsl/GeoLocation.java
@@ -1,8 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.client.dsl;
-import org.apache.commons.text.StringEscapeUtils;
-
public class GeoLocation extends QueryChain {
private final String fieldName;
@@ -40,6 +38,6 @@ public class GeoLocation extends QueryChain {
@Override
public String toString() {
- return Text.format("geoLocation(%s, %f, %f, \"%s\")", fieldName, longitude, latitude, StringEscapeUtils.escapeJava(radius));
+ return Text.format("geoLocation(%s, %f, %f, %s)", fieldName, longitude, latitude, Q.toJson(radius));
}
}