Skip to content

Commit fb7025f

Browse files
authored
Merge pull request #49 from embulk/fix-validation-for-test
Use java.util.regex.Pattern for host name validation
2 parents 3e91f5c + fddb336 commit fb7025f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/org/embulk/output/sftp/SftpUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.InputStream;
2323
import java.net.URI;
2424
import java.net.URISyntaxException;
25+
import java.util.regex.Pattern;
2526

2627
import static org.embulk.output.sftp.SftpFileOutputPlugin.PluginTask;
2728
import static org.embulk.spi.util.RetryExecutor.retryExecutor;
@@ -271,13 +272,14 @@ public void onGiveup(Exception firstException, Exception lastException) throws R
271272

272273
public void validateHost(PluginTask task)
273274
{
274-
if (task.getHost().contains("%s")) {
275+
Pattern pattern = Pattern.compile("\\s");
276+
if (pattern.matcher(task.getHost()).find()) {
275277
throw new ConfigException("'host' can't contain spaces");
276278
}
277279
getSftpFileUri("/");
278280

279281
if (task.getProxy().isPresent() && task.getProxy().get().getHost().isPresent()) {
280-
if (task.getProxy().get().getHost().get().contains("%s")) {
282+
if (pattern.matcher(task.getProxy().get().getHost().get()).find()) {
281283
throw new ConfigException("'proxy.host' can't contains spaces");
282284
}
283285
}

0 commit comments

Comments
 (0)