cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6769] Avoiding escaping the underscore char if preferred by the user
Date Wed, 10 Feb 2016 12:25:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 23112f714 -> 791141099


[CXF-6769] Avoiding escaping the underscore char if preferred by the user


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

Branch: refs/heads/3.1.x-fixes
Commit: 791141099e5c0b3bebafa76a2391cc1e6aec3d39
Parents: 23112f7
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Feb 10 12:23:17 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Feb 10 12:25:26 2016 +0000

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java   | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/79114109/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
index 45013c5..4c97d57 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
@@ -29,6 +29,7 @@ import java.util.logging.Logger;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.ext.search.sql.SQLPrinterVisitor;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 
 public final class SearchUtils {
@@ -42,6 +43,7 @@ public final class SearchUtils {
     public static final String BEAN_PROPERTY_CONVERTER = "search.bean.property.converter";
     public static final String SEARCH_VISITOR_PROPERTY = "search.visitor";
     public static final String DECODE_QUERY_VALUES = "search.decode.values";
+    public static final String ESCAPE_UNDESCORE_CHAR = "search.escape.underscore.char";
     
     private static final Logger LOG = LogUtils.getL7dLogger(SearchUtils.class);
     
@@ -59,6 +61,11 @@ public final class SearchUtils {
         return null;        
     }
     
+    private static boolean escapeUnderscoreChar() {
+        Message m = PhaseInterceptorChain.getCurrentMessage();
+        return MessageUtils.getContextualBoolean(m, ESCAPE_UNDESCORE_CHAR, true);
+    }
+    
     public static SimpleDateFormat getContextualDateFormatOrDefault(final String pattern)
{
         final SimpleDateFormat format = getContextualDateFormat();
         return format != null ? format : new SimpleDateFormat(pattern);        
@@ -100,7 +107,7 @@ public final class SearchUtils {
         if (value.contains("\\")) {
             value = value.replaceAll("\\\\", "\\\\\\\\"); 
         }
-        if (value.contains("_")) {
+        if (value.contains("_") && escapeUnderscoreChar()) {
             value = value.replaceAll("_", "\\\\_");
         }
         if (value.contains("%")) {


Mime
View raw message