You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/02/06 15:07:26 UTC
[syncope] branch master updated: Ensuring values are properly
encoded for FIQL
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new b1d81c0 Ensuring values are properly encoded for FIQL
b1d81c0 is described below
commit b1d81c0125dd2aa5f1108bec636c48654db9fc10
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Thu Feb 6 15:56:37 2020 +0100
Ensuring values are properly encoded for FIQL
---
.../client/console/panels/search/SearchUtils.java | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
index 4b9c991..d9bdcb1 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
@@ -26,6 +26,8 @@ import java.util.Optional;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.apache.commons.collections4.BidiMap;
+import org.apache.commons.collections4.bidimap.DualHashBidiMap;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -49,9 +51,20 @@ public final class SearchUtils implements Serializable {
private static final long serialVersionUID = 398381905376547084L;
+ public static final Function<SearchClause, CompleteCondition> NO_CUSTOM_CONDITION = clause -> null;
+
private static final Logger LOG = LoggerFactory.getLogger(SearchUtils.class);
- public static final Function<SearchClause, CompleteCondition> NO_CUSTOM_CONDITION = clause -> null;
+ private static final BidiMap<String, String> ENCODINGS = new DualHashBidiMap<String, String>() {
+
+ private static final long serialVersionUID = 5636572627689425575L;
+
+ {
+ put(",", "%252C");
+ put(";", "%253B");
+ put("+", "%252B");
+ }
+ };
private static Pattern getTypeConditionPattern(final String type) {
return Pattern.compile(String.format(";\\$type==%s|\\$type==%s;", type, type));
@@ -115,7 +128,9 @@ public final class SearchUtils implements Serializable {
String property = sc.getCondition().getKeySet().iterator().next();
clause.setProperty(property);
- String value = sc.getCondition().get(property).replace("%252C", ",").replace("%253B", ";");
+
+ String value = ENCODINGS.values().stream().
+ reduce(sc.getCondition().get(property), (s, v) -> s.replace(v, ENCODINGS.getKey(v)));
clause.setValue(value);
LOG.debug("Condition: " + sc.getCondition());
@@ -224,7 +239,8 @@ public final class SearchUtils implements Serializable {
if (clause.getType() != null) {
String value = clause.getValue() == null
? null
- : clause.getValue().replace(",", "%252C").replace(";", "%253B");
+ : ENCODINGS.keySet().stream().
+ reduce(clause.getValue(), (s, k) -> s.replace(k, ENCODINGS.get(k)));
switch (clause.getType()) {
case GROUP_MEMBER: