Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#9739 - URLValidator now allows two slashes in the path component of the URL #9750

Merged
merged 4 commits into from
May 21, 2024
Merged
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
7 changes: 7 additions & 0 deletions doc/release-notes/9739-url-validator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Release Highlights

### URL validation is more permissive

Url validation now allows two slashes in the path component of the URL. (#9750)
Among other things, this allows metadata fields of `url` type to be filled with more complex url such as https://archive.softwareheritage.org/browse/directory/561bfe6698ca9e58b552b4eb4e56132cac41c6f9/?origin_url=https://github.com/gem-pasteur/macsyfinder&revision=868637fce184865d8e0436338af66a2648e8f6e1&snapshot=1bde3cb370766b10132c4e004c7cb377979928d1

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static boolean isURLValid(String value) {
* @return true when valid (null is also valid) or false
*/
public static boolean isURLValid(String value, String[] schemes) {
UrlValidator urlValidator = new UrlValidator(schemes);
UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_2_SLASHES);
return value == null || urlValidator.isValid(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static Stream<Arguments> stdUrlExamples() {
Arguments.of(true, "http://foobar.com:9101"),
Arguments.of(true, "ftp://[email protected]"),
Arguments.of(false, "cnn.com"),
Arguments.of(false, "smb://[email protected]")
Arguments.of(false, "smb://[email protected]"),
// case of a real permalink that requires UrlValidator.ALLOW_2_SLASHES
Arguments.of(true, "https://archive.softwareheritage.org/swh:1:dir:561bfe6698ca9e58b552b4eb4e56132cac41c6f9;origin=https://github.com/gem-pasteur/macsyfinder;visit=swh:1:snp:1bde3cb370766b10132c4e004c7cb377979928d1;anchor=swh:1:rev:868637fce184865d8e0436338af66a2648e8f6e1")
);
}

Expand Down
Loading