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:23:32 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 351364f7f -> dac1fbc21


[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/dac1fbc2
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/dac1fbc2
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/dac1fbc2

Branch: refs/heads/master
Commit: dac1fbc215031699d0a554e433311685ccaef74f
Parents: 351364f
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:23:17 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/dac1fbc2/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