Skip to content

Commit

Permalink
Fix handling of percent-encoded spaces in Windows batch files (#31034)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasontedor authored Jun 1, 2018
1 parent a8c643e commit 6fb1e4a
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion distribution/src/bin/elasticsearch-keystore.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setlocal enableextensions

call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.common.settings.KeyStoreCli ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
2 changes: 1 addition & 1 deletion distribution/src/bin/elasticsearch-plugin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setlocal enableextensions
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.plugins.PluginCli ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
2 changes: 1 addition & 1 deletion distribution/src/bin/elasticsearch-translog.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setlocal enableextensions

call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.index.translog.TranslogToolCli ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.core.ssl.CertificateTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal enableextensions
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-watcher-env
call "%~dp0elasticsearch-cli.bat" ^
org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^
%* ^
%%* ^
|| exit /b 1

endlocal
Expand Down

0 comments on commit 6fb1e4a

Please sign in to comment.