Skip to content

Commit fa2acf1

Browse files
author
Vladimir Kotal
committed
use java.net.URI to perform the verification
1 parent 53d11a0 commit fa2acf1

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

opengrok-indexer/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
153153
<artifactId>org.suigeneris.jrcs.rcs</artifactId>
154154
<version>0.4.2</version>
155155
</dependency>
156-
<dependency>
157-
<groupId>commons-validator</groupId>
158-
<artifactId>commons-validator</artifactId>
159-
<version>1.4.0</version>
160-
</dependency>
161156
</dependencies>
162157

163158
<build>

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import java.io.IOException;
2929
import java.lang.reflect.Field;
3030
import java.lang.reflect.InvocationTargetException;
31+
import java.net.MalformedURLException;
32+
import java.net.URI;
33+
import java.net.URISyntaxException;
3134
import java.nio.file.Paths;
3235
import java.text.ParseException;
3336
import java.util.ArrayList;
@@ -46,7 +49,6 @@
4649
import java.util.logging.Logger;
4750
import java.util.stream.Collectors;
4851

49-
import org.apache.commons.validator.routines.UrlValidator;
5052
import org.opengrok.indexer.Info;
5153
import org.opengrok.indexer.analysis.AnalyzerGuru;
5254
import org.opengrok.indexer.analysis.AnalyzerGuruHelp;
@@ -732,9 +734,13 @@ public static String[] parseOptions(String[] argv) throws ParseException {
732734
parser.on("-U", "--host", "=protocol://host:port/contextPath",
733735
"Send the current configuration to the specified address").Do(webAddr -> {
734736
host = (String) webAddr;
735-
String[] schemes = {"http", "https"};
736-
UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_LOCAL_URLS);
737-
if (!urlValidator.isValid(host)) {
737+
try {
738+
URI uri = new URI(host);
739+
String scheme = uri.getScheme();
740+
if (!scheme.equals("http") && !scheme.equals("https")) {
741+
die("URI '" + host + "' does not have HTTP/HTTPS scheme");
742+
}
743+
} catch (URISyntaxException e) {
738744
die("URL '" + host + "' is not valid.");
739745
}
740746

0 commit comments

Comments
 (0)