atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [1/2] atlas git commit: ATLAS-2118: basic search fix - incorrect results for contains operator
Date Thu, 14 Sep 2017 20:29:56 GMT
Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 3dc90a221 -> cb8c4a704


ATLAS-2118: basic search fix - incorrect results for contains operator

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit a785e935dc77234f783013f51ff23d8c9f0eca59)


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/adaa9c43
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/adaa9c43
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/adaa9c43

Branch: refs/heads/branch-0.8
Commit: adaa9c439df69d8dafa85f1e1cb57aee4769f0b4
Parents: 3dc90a2
Author: apoorvnaik <apoorvnaik@apache.org>
Authored: Wed Sep 6 11:26:51 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Thu Sep 14 13:22:43 2017 -0700

----------------------------------------------------------------------
 .../apache/atlas/discovery/SearchProcessor.java | 30 +++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/adaa9c43/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
index 1cb2249..f6ff8d4 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
@@ -220,6 +220,8 @@ public abstract class SearchProcessor {
             }
         } else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
             try {
+
+
                 if (insideOrCondition && !isIndexSearchable(filterCriteria, structType))
{
                     ret = false;
                 }
@@ -614,8 +616,34 @@ public abstract class SearchProcessor {
         }
     }
 
+    // ATLAS-2118: Reserved regex characters in attribute value can cause the graph query
to fail when parsing the contains regex
     private String getContainsRegex(String attributeValue) {
-        return ".*" + attributeValue + ".*";
+        StringBuilder escapedAttrVal = new StringBuilder(".*");
+
+        for (int i = 0; i < attributeValue.length(); i++) {
+            final char c = attributeValue.charAt(i);
+
+            switch (c) {
+                case '+':
+                case '|':
+                case '(':
+                case '{':
+                case '[':
+                case '*':
+                case '?':
+                case '$':
+                case '/':
+                case '^':
+                    escapedAttrVal.append('\\');
+                    break;
+            }
+
+            escapedAttrVal.append(c);
+        }
+
+        escapedAttrVal.append(".*");
+
+        return escapedAttrVal.toString();
     }
 
     private String getSuffixRegex(String attributeValue) {


Mime
View raw message