Skip to content

Commit c0d467f

Browse files
refactor: Use SchemaNames to escape and sanitze labels used in SpEL.
Signed-off-by: Michael Simons <[email protected]>
1 parent 980552e commit c0d467f

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/main/java/org/springframework/data/neo4j/repository/query/Neo4jSpelSupport.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
import java.io.Serial;
1919
import java.util.Collection;
2020
import java.util.LinkedHashMap;
21-
import java.util.Locale;
2221
import java.util.Map;
2322
import java.util.concurrent.locks.StampedLock;
24-
import java.util.regex.Matcher;
2523
import java.util.regex.Pattern;
2624
import java.util.stream.Collectors;
2725

@@ -248,10 +246,7 @@ public static String renderQueryIfExpressionOrReturnQuery(String query, Neo4jMap
248246
.getRequiredPersistentEntity(metadata.getJavaType());
249247
evalContext.setVariable(ENTITY_NAME, requiredPersistentEntity.getStaticLabels()
250248
.stream()
251-
.map(l -> {
252-
Matcher matcher = LABEL_AND_TYPE_QUOTATION.matcher(l);
253-
return String.format(Locale.ENGLISH, "`%s`", matcher.replaceAll("``"));
254-
})
249+
.map(l -> SchemaNames.sanitize(l, true).orElseThrow())
255250
.collect(Collectors.joining(":")));
256251

257252
query = potentiallyQuoteExpressionsParameter(query);

0 commit comments

Comments
 (0)