Skip to content

Commit ed50f0c

Browse files
committed
Ensuring to escape Neo4j property values for search
1 parent 8879551 commit ed50f0c

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/Neo4jAnySearchDAO.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected static void appendPlainAttrCond(
132132

133133
protected static String escapeIfString(final String value, final boolean isStr) {
134134
return isStr
135-
? new StringBuilder().append('"').append(value).append('"').toString()
135+
? new StringBuilder().append('"').append(AnyRepoExt.escapeForLikeRegex(value)).append('"').toString()
136136
: value;
137137
}
138138

@@ -648,7 +648,7 @@ protected AnyCondQuery getQuery(
648648
if (!SyncopeConstants.UUID_PATTERN.matcher(cond.getExpression()).matches()) {
649649
Realm realm = realmSearchDAO.findByFullPath(cond.getExpression()).
650650
orElseThrow(() -> new IllegalArgumentException(
651-
"Invalid Realm full path: " + cond.getExpression()));
651+
"Invalid Realm full path: " + cond.getExpression()));
652652
cond.setExpression(realm.getKey());
653653
}
654654

@@ -842,7 +842,7 @@ protected void wrapQuery(
842842
Stream.concat(
843843
queryInfo.fields().stream(),
844844
orderBy.stream().filter(clause -> !"id".equals(clause.getProperty())
845-
&& anyUtils.getField(clause.getProperty()).isPresent()).map(Order::getProperty)).
845+
&& anyUtils.getField(clause.getProperty()).isPresent()).map(Order::getProperty)).
846846
distinct().forEach(field -> match.append(", n.").append(field).append(" AS ").append(field));
847847

848848
// take plain schemas into account

‎core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/Neo4jRealmSearchDAO.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected static void appendPlainAttrCond(
101101

102102
protected static String escapeIfString(final String value, final boolean isStr) {
103103
return isStr
104-
? new StringBuilder().append('"').append(value).append('"').toString()
104+
? new StringBuilder().append('"').append(AnyRepoExt.escapeForLikeRegex(value)).append('"').toString()
105105
: value;
106106
}
107107

@@ -278,7 +278,7 @@ protected void wrapQuery(
278278
Stream.concat(
279279
queryInfo.fields().stream(),
280280
orderBy.stream().filter(clause -> !"id".equals(clause.getProperty())
281-
&& realmUtils.getField(clause.getProperty()).isPresent()).map(Order::getProperty)).
281+
&& realmUtils.getField(clause.getProperty()).isPresent()).map(Order::getProperty)).
282282
distinct().forEach(field -> match.append(", n.").append(field).append(" AS ").append(field));
283283

284284
// take plain schemas into account

0 commit comments

Comments
 (0)