applied a change on behalf of Jesse.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1037 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2006-11-07 02:05:30 +00:00
1 parent bc7085a770
commit 4e1cf37bf8
1 file changed
+23 -1
+23 -1
View File
@@ -184,7 +184,7 @@ public class Mailer extends Publisher {
// workspaceDir will not normally end with one;
// workspaceDir.toURI() will end with '/' if and only if workspaceDir.exists() at time of call
wsPattern = Pattern.compile("(" +
Pattern.quote(workspaceDir.getPath()) + "|" + Pattern.quote(workspaceDir.toURI().toString()) + ")[/\\\\]?([^:#\\s]*)");
quoteRegexp(workspaceDir.getPath()) + "|" + quoteRegexp(workspaceDir.toURI().toString()) + ")[/\\\\]?([^:#\\s]*)");
}
for (int i = start; i < lines.length; i++) {
String line = lines[i];
@@ -414,4 +414,26 @@ public class Mailer extends Publisher {
}
}
}
/**
* Copied from JDK5, to avoid 5.0 dependency.
*/
private static String quoteRegexp(String s) {
int slashEIndex = s.indexOf("\\E");
if (slashEIndex == -1)
return "\\Q" + s + "\\E";
StringBuilder sb = new StringBuilder(s.length() * 2);
sb.append("\\Q");
slashEIndex = 0;
int current = 0;
while ((slashEIndex = s.indexOf("\\E", current)) != -1) {
sb.append(s.substring(current, slashEIndex));
current = slashEIndex + 2;
sb.append("\\E\\\\E\\Q");
}
sb.append(s.substring(current, s.length()));
sb.append("\\E");
return sb.toString();
}
}