Fix scripting plugin commandline processing
This commit is contained in:
+6
-3
@@ -111,11 +111,14 @@ class ScriptingCommandLineProcessor : CommandLineProcessor {
|
||||
val currentEnv = configuration.getMap(ScriptingConfigurationKeys.LEGACY_SCRIPT_RESOLVER_ENVIRONMENT_OPTION).toMutableMap()
|
||||
// parses key/value pairs in the form <key>=<value>, where
|
||||
// <key> - is a single word (\w+ pattern)
|
||||
// <value> - optionally quoted string with allowed escaped chars (only double-quote and backslash chars are supported)
|
||||
// <value> - optionally quoted string with allowed escaped chars (only double-quote, comma and backslash chars are supported)
|
||||
// TODO: implement generic unescaping
|
||||
// TODO: consider switching to simple parser - current approach is too complicated already and doesn't handle quoted commas (unless they are escaped)
|
||||
val envParseRe = """(\w+)=(?:"([^"\\]*(\\.[^"\\]*)*)"|([^\s]*))""".toRegex()
|
||||
val unescapeRe = """\\(["\\])""".toRegex()
|
||||
for (envParam in value.split(',')) {
|
||||
val unescapeRe = """\\(["\\,])""".toRegex()
|
||||
val splitRe = """(?:\\.|[^,\\]++)*""".toRegex()
|
||||
val splitMatches = splitRe.findAll(value)
|
||||
for (envParam in splitMatches.map { it.value }.filter { it.isNotBlank() }) {
|
||||
val match = envParseRe.matchEntire(envParam)
|
||||
if (match == null || match.groupValues.size < 4 || match.groupValues[1].isBlank()) {
|
||||
throw CliOptionProcessingException("Unable to parse script-resolver-environment argument $envParam")
|
||||
|
||||
Reference in New Issue
Block a user