Skip to content

Commit

Permalink
[JENKINS-47909] Handle false hex escapes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Nov 9, 2017
1 parent 397b4fa commit b675122
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/main/java/jenkins/model/IdStrategy.java
Expand Up @@ -303,7 +303,11 @@ public String idFromFilename(@Nonnull String filename) {
} else {
break;
}
buf.append(Character.valueOf((char)Integer.parseInt(hex.toString(), 16)));
try {
buf.append(Character.valueOf((char)Integer.parseInt(hex.toString(), 16)));
} catch (NumberFormatException x) {
buf.append('$').append(hex);
}
}
}
return buf.toString();
Expand Down Expand Up @@ -509,7 +513,11 @@ public String idFromFilename(@Nonnull String filename) {
} else {
break;
}
buf.append(Character.valueOf((char)Integer.parseInt(hex.toString(), 16)));
try {
buf.append(Character.valueOf((char)Integer.parseInt(hex.toString(), 16)));
} catch (NumberFormatException x) {
buf.append('$').append(hex);
}
}
}
return buf.toString();
Expand Down
1 change: 1 addition & 0 deletions core/src/test/java/jenkins/model/IdStrategyTest.java
Expand Up @@ -29,6 +29,7 @@ public void caseInsensitive() {
assertCaseInsensitiveRoundTrip("NUL", "$006eul");
assertEquals("foo", idStrategy.idFromFilename("~foo"));
assertEquals("0123 _-@a", idStrategy.idFromFilename("0123 _-@~a"));
assertEquals("big$money", idStrategy.idFromFilename("big$money"));
}

@Test
Expand Down

0 comments on commit b675122

Please sign in to comment.