Skip to content

Commit 43dde4d

Browse files
committed
Fix handling of percent-encoded spaces in Windows batch files (#31034)
If you invoke elasticsearch-plugin (or any other CLI script on Windows) with a path that has a percent-encoded space (or any other percent-encoded character) because the CLI scripts now shell into a common shell script (elasticsearch-cli) the percent-encoded space ends up being interpreted as a parameter. For example passing install --batch file:/c:/encoded%20%space/analysis-icu-7.0.0.zip to elasticsearch-plugin leads to the %20 being interpreted as %2 followed by a zero. Here, the %2 is interpreted as the second parameter (--batch) and the InstallPluginCommand class ends up seeing file:/c/encoded--batch0space/analysis-icu-7.0.0.zip as the path which will not exist. This commit addresses this by escaping the %* that is used to pass the parameters to the common CLI script so that the common script sees the correct parameters without the %2 being substituted.
1 parent 01c0654 commit 43dde4d

11 files changed

+11
-11
lines changed

distribution/src/bin/elasticsearch-keystore.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ setlocal enableextensions
55

66
call "%~dp0elasticsearch-cli.bat" ^
77
org.elasticsearch.common.settings.KeyStoreCli ^
8-
%* ^
8+
%%* ^
99
|| exit /b 1
1010

1111
endlocal

distribution/src/bin/elasticsearch-plugin.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setlocal enableextensions
66
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli
77
call "%~dp0elasticsearch-cli.bat" ^
88
org.elasticsearch.plugins.PluginCli ^
9-
%* ^
9+
%%* ^
1010
|| exit /b 1
1111

1212
endlocal

distribution/src/bin/elasticsearch-translog.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ setlocal enableextensions
55

66
call "%~dp0elasticsearch-cli.bat" ^
77
org.elasticsearch.index.translog.TranslogToolCli ^
8-
%* ^
8+
%%* ^
99
|| exit /b 1
1010

1111
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.core.ssl.CertificateTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/security/src/main/bin/elasticsearch-users.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal enableextensions
1010
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-watcher-env
1111
call "%~dp0elasticsearch-cli.bat" ^
1212
org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^
13-
%* ^
13+
%%* ^
1414
|| exit /b 1
1515

1616
endlocal

0 commit comments

Comments
 (0)