Skip to content

Quoting of option values is broken #1291

@cmerkel-eitco

Description

@cmerkel-eitco

In version 3.x you could execute a command using a quoted option value like that:

select --from some_table --where "counter=7"

In version 4.0.0, the quotes are ignored and the value for the where option is parsed to counter.

I did some debugging and found an issue in the class org.springframework.shell.core.command.DefaultCommandParser. In the parseOption method, the string containing the option name and the option value is split using word.split("="). This splits the quoted value, too. This seems unnecessary, as the entire input string was already split using a regular expression which checks for quoted parts of the string. Using word.split("=", 2) should return the correct result.

Additionally, I would recommend to make the regular expression used in the parse method a bit more robust by changing it from " (?=(?:[^"]*"[^"]*")*[^"]*$)" to "\s+(?=(?:[^"]*"[^"]*")*[^"]*$)". This would match one or more spaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions