rootvector2 commented on code in PR #774:
URL: https://github.com/apache/commons-vfs/pull/774#discussion_r3629199057
##########
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java:
##########
@@ -47,6 +47,24 @@ public final class UriParser {
private static final char LOW_MASK = 0x0F;
+ /**
+ * Returns the value of an ASCII hexadecimal digit, or {@code -1} if the
character is not one.
+ * <p>
+ * Unlike {@link Character#digit(char, int)}, this only accepts the ASCII
digits {@code 0-9}, {@code a-f} and
+ * {@code A-F} that RFC 3986 permits in a percent-encoding, so Unicode
look-alikes such as the fullwidth digits are
+ * rejected instead of silently decoded.
+ * </p>
+ *
+ * @param ch the character to convert.
+ * @return the value 0-15, or {@code -1} if {@code ch} is not an ASCII
hexadecimal digit.
+ */
+ private static int hexDigit(final char ch) {
Review Comment:
done, `hexDigit` now delegates the check to `CharUtils.isHex` and keeps
`Character.digit` just for the nibble value. `UriParserTest` still passes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]