提交 61ec6a94 编写于 作者: M Michael Strasser 提交者: Vojtech Juranek

safe() also replaces '%' with '_'

上级 b03ad296
......@@ -365,7 +365,7 @@ public abstract class TestObject extends hudson.tasks.junit.TestObject {
*/
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('#', '_');
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
......
......@@ -11,7 +11,7 @@ public class TestObjectTest {
@Test
public void testSafe() {
String name = "Foo#approve! is called by approve_on_foo?xyz/\\:";
String name = "Foo#approve! is called by approve_on_foo?xyz/\\: 50%";
String encoded = TestObject.safe(name);
Assert.assertFalse(encoded.contains("#"));
......@@ -19,6 +19,7 @@ public class TestObjectTest {
Assert.assertFalse(encoded.contains("\\"));
Assert.assertFalse(encoded.contains("/"));
Assert.assertFalse(encoded.contains(":"));
Assert.assertFalse(encoded.contains("%"));
}
@Test public void uniquifyName() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册