Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | yes |
RFC? | yes |
Symfony version | 3.4.2 (and others) |
#24987 introduced a bug in hasParameterOption. If a short option has a value, then hasParameterOption will search the value for additional short options.
#25487 submitted a fix for this bug, but the fix appears to be incorrect.
The current implementation of parseShortOption
is as follows:
/**
* Parses a short option.
*
* @param string $token The current token
*/
private function parseShortOption($token)
{
$name = substr($token, 1);
if (strlen($name) > 1) {
if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
// an option with a value (with no space)
$this->addShortOption($name[0], substr($name, 1));
} else {
$this->parseShortOptionSet($name);
}
} else {
$this->addShortOption($name, null);
}
}
In particular, note the substr($name, 1)
. If there is a short option -e
that takes a value, then -etest
will provide the value test
to the -e
option. See also the implementation of parseShortOptionSet
, which has similar logic. No =
is assumed or accounted for.
#25487 fixed the bug of #24987 by assuming that the value of a short option was formatted as -e=test
; however, this is inconsistent with the implementation of the parsing functions.
My testing seems to uphold these observations, but please LMK if I have made an error somewhere. I'm not sure if there is a better solution than reverting #24987.