You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2010/07/27 08:25:25 UTC

svn commit: r979552 - /logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java

Author: sdeboy
Date: Tue Jul 27 06:25:24 2010
New Revision: 979552

URL: http://svn.apache.org/viewvc?rev=979552&view=rev
Log:
Updating meta char replacement to ensure all regexp characters are escaped properly

Modified:
    logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java

Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java?rev=979552&r1=979551&r2=979552&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java (original)
+++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java Tue Jul 27 06:25:24 2010
@@ -813,14 +813,24 @@ public class LogFilePatternReceiver exte
    * @return string
    */
   private String replaceMetaChars(String input) {
+    //escape backslash first since that character is used to escape the remaining meta chars
+    input = globalReplace("\\", "\\\\", input);
+
+    //don't escape star - it's used as the wildcard
+    input = globalReplace("]", "\\]", input);
+    input = globalReplace("[", "\\[", input);
+    input = globalReplace("^", "\\^", input);
+    input = globalReplace("$", "\\$", input);
+    input = globalReplace(".", "\\.", input);
+    input = globalReplace("|", "\\|", input);
+    input = globalReplace("?", "\\?", input);
+    input = globalReplace("+", "\\+", input);
     input = globalReplace("(", "\\(", input);
     input = globalReplace(")", "\\)", input);
-    input = globalReplace("[", "\\[", input);
-    input = globalReplace("]", "\\]", input);
+    input = globalReplace("-", "\\-", input);
     input = globalReplace("{", "\\{", input);
     input = globalReplace("}", "\\}", input);
     input = globalReplace("#", "\\#", input);
-    input = globalReplace("/", "\\/", input);
     return input;
   }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org