sebbASF commented on code in PR #383:
URL: https://github.com/apache/commons-validator/pull/383#discussion_r3379704839
##########
src/main/java/org/apache/commons/validator/routines/UrlValidator.java:
##########
@@ -474,6 +477,17 @@ protected boolean isValidFragment(final String fragment) {
return isOff(NO_FRAGMENTS);
}
+ private String decodePath(final String path) {
+ try {
+ // URLDecoder.decode converts '+' to a space character.
+ // Since '+' is a valid literal character in a URI path,
+ // we escape it to '%2B' before decoding to preserve it.
+ return URLDecoder.decode(path.replace("+", "%2B"),
StandardCharsets.UTF_8.name());
+ } catch (final UnsupportedEncodingException | IllegalArgumentException
e) {
+ return path;
Review Comment:
If the path cannot be decoded, it should be treated as invalid, same as is
done for URISyntaxException in the method isValidPath
##########
src/main/java/org/apache/commons/validator/routines/UrlValidator.java:
##########
@@ -474,6 +477,17 @@ protected boolean isValidFragment(final String fragment) {
return isOff(NO_FRAGMENTS);
}
+ private String decodePath(final String path) {
+ try {
+ // URLDecoder.decode converts '+' to a space character.
+ // Since '+' is a valid literal character in a URI path,
+ // we escape it to '%2B' before decoding to preserve it.
Review Comment:
This is unnecessary
--
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]