Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-27974]: Safe URL for empty className
  • Loading branch information
ydubreuil committed Apr 16, 2015
1 parent ba51b56 commit 07deb07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/hudson/tasks/test/TestObject.java
Expand Up @@ -373,8 +373,12 @@ protected final String uniquifyName(Collection<? extends TestObject> siblings, S
* Replaces URL-unsafe characters.
*/
public static String safe(String s) {
// this still seems to be a bit faster than a single replace with regexp
return s.replace('/', '_').replace('\\', '_').replace(':', '_').replace('?', '_').replace('#', '_').replace('%', '_');
if (s.isEmpty()) {
return "(empty)";
} else {
// this still seems to be a bit faster than a single replace with regexp
return s.replace('/', '_').replace('\\', '_').replace(':', '_').replace('?', '_').replace('#', '_').replace('%', '_');
}

// Note: we probably should some helpers like Commons URIEscapeUtils here to escape all invalid URL chars, but then we
// still would have to escape /, ? and so on
Expand Down

0 comments on commit 07deb07

Please sign in to comment.