Hi, I not added the backslash because backslashes are not allowed in emailaddresses, anyway It can't harm ;-)
Thx, Norman 2009/5/31 <[email protected]>: > Author: bago > Date: Sun May 31 12:22:44 2009 > New Revision: 780418 > > URL: http://svn.apache.org/viewvc?rev=780418&view=rev > Log: > Also add escaping for backslash in regex replace strings (JSPF-71) > From javadocs, both dollar and backslash need escaping. > (also replaced tabs with spaces for our formatting convention). > > Modified: > > james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java > > james/jspf/trunk/resolver/src/test/java/org/apache/james/jspf/core/MacroExpandTest.java > > Modified: > james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java > URL: > http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java?rev=780418&r1=780417&r2=780418&view=diff > ============================================================================== > --- > james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java > (original) > +++ > james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java > Sun May 31 12:22:44 2009 > @@ -573,16 +573,16 @@ > * @return escaped string > */ > private String escapeForMatcher(String raw) { > - StringBuffer sb= new StringBuffer(); > - > - for (int i = 0; i < raw.length(); i++) { > - char c = raw.charAt(i); > - if (c == '$') { > - sb.append('\\'); > - } > - sb.append(c); > - } > - return sb.toString(); > + StringBuffer sb = new StringBuffer(); > + > + for (int i = 0; i < raw.length(); i++) { > + char c = raw.charAt(i); > + if (c == '$' || c == '\\') { > + sb.append('\\'); > + } > + sb.append(c); > + } > + return sb.toString(); > } > > } > \ No newline at end of file > > Modified: > james/jspf/trunk/resolver/src/test/java/org/apache/james/jspf/core/MacroExpandTest.java > URL: > http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/test/java/org/apache/james/jspf/core/MacroExpandTest.java?rev=780418&r1=780417&r2=780418&view=diff > ============================================================================== > --- > james/jspf/trunk/resolver/src/test/java/org/apache/james/jspf/core/MacroExpandTest.java > (original) > +++ > james/jspf/trunk/resolver/src/test/java/org/apache/james/jspf/core/MacroExpandTest.java > Sun May 31 12:22:44 2009 > @@ -188,16 +188,33 @@ > } > > public void testLocalPartWithSpecialChars() throws PermErrorException { > - > - > - > assertEquals("+exists:cl.192.0.2.3.fr.test{[email protected]",defIp4me.expand("+exists:CL.%{i}.FR.%{s}.spf.test.com", > new rfcIP4MacroData() { > - public String getMailFrom() { > - return "test{[email protected]"; > - } > - public String getCurrentSenderPart() { > - return "test{$LNAME}"; > - } > - }, MacroExpand.DOMAIN)); > + > + assertEquals( > + > "+exists:cl.192.0.2.3.fr.test{[email protected]", > + defIp4me.expand("+exists:CL.%{i}.FR.%{s}.spf.test.com", > + new rfcIP4MacroData() { > + public String getMailFrom() { > + return "test{[email protected]"; > + } > + > + public String getCurrentSenderPart() { > + return "test{$LNAME}"; > + } > + }, MacroExpand.DOMAIN)); > + > + // not sure if \ is allowed in email, but anyway make sure we > correctly handle also backslash. > + assertEquals( > + > "+exists:cl.192.0.2.3.fr.tes\\t{[email protected]", > + defIp4me.expand("+exists:CL.%{i}.FR.%{s}.spf.test.com", > + new rfcIP4MacroData() { > + public String getMailFrom() { > + return "tes\\t{[email protected]"; > + } > + > + public String getCurrentSenderPart() { > + return "tes\\t{$LNAME}"; > + } > + }, MacroExpand.DOMAIN)); > } > > } > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
