Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ public static long decodeKey(final String encoded) {
}

final String digits = encoded.replaceAll("[^0-9]", "");
final long product = Long.parseLong(digits);
final long product;
try {
product = Long.parseLong(digits);
}
catch (NumberFormatException e){
throw new NumberFormatException("Passed key to decode is not a parsable long");
}
return product / numSpaces;
}
}
7 changes: 7 additions & 0 deletions src/test/java/org/jboss/as/websocket/HandshakeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ public void testHandshake() {
"B..r..\\8".getBytes())));
}

@Test(expected=NumberFormatException.class)
public void testHandshakeInvalidDecodeKey() {
System.out.println(new String(Hybi00Handshake.solve("MD5", Hybi00Handshake.decodeKey(""),
Hybi00Handshake.decodeKey(""),
"".getBytes())));
}

}