plugins: fix print of url when it contains spaces

This commit is contained in:
Britta Weber 2015-09-11 12:26:04 +02:00
parent 380fe52b30
commit 2c618a11de
2 changed files with 11 additions and 1 deletions

View File

@ -34,6 +34,7 @@ import org.elasticsearch.plugins.PluginManager.OutputMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Locale;
import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd;
@ -221,7 +222,7 @@ public class PluginManagerCliParser extends CliTool {
if (name != null) {
terminal.println("-> Installing " + Strings.coalesceToEmpty(name) + "...");
} else {
terminal.println("-> Installing from " + url + "...");
terminal.println("-> Installing from " + URLDecoder.decode(url.toString(), "UTF-8") + "...");
}
pluginManager.downloadAndExtract(name, terminal);
return ExitStatus.OK;

View File

@ -19,12 +19,14 @@
package org.elasticsearch.plugins;
import org.elasticsearch.common.cli.CliTool;
import org.elasticsearch.common.cli.CliToolTestCase;
import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.cli.CliTool.ExitStatus.OK_AND_EXIT;
import static org.elasticsearch.common.cli.CliTool.ExitStatus.IO_ERROR;
import static org.hamcrest.Matchers.*;
public class PluginManagerCliTests extends CliToolTestCase {
@ -50,4 +52,11 @@ public class PluginManagerCliTests extends CliToolTestCase {
assertThat(new PluginManagerCliParser(terminal).execute(args("list -h")), is(OK_AND_EXIT));
assertTerminalOutputContainsHelpFile(terminal, "/org/elasticsearch/plugins/plugin-list.help");
}
public void testUrlSpacesInPath() {
CliToolTestCase.CaptureOutputTerminal terminal = new CliToolTestCase.CaptureOutputTerminal();
CliTool.ExitStatus execute = new PluginManagerCliParser(terminal).execute(args("install file://foo%20deps"));
assertThat(execute.status(), is(IO_ERROR.status()));
}
}