Skip to content

Commit

Permalink
[Console] Revert StringInput bc break from #45088
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow authored and fabpot committed Mar 1, 2022
1 parent 79e0887 commit 2e322c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Input/StringInput.php
Expand Up @@ -24,7 +24,8 @@
*/
class StringInput extends ArgvInput
{
public const REGEX_STRING = '([^\s\\\\]+?)';
public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
public const REGEX_UNQUOTED_STRING = '([^\s\\\\]+?)';
public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';

/**
Expand Down Expand Up @@ -64,7 +65,7 @@ private function tokenize(string $input): array
$token .= $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
$token .= stripcslashes(substr($match[0], 1, -1));
} elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
} elseif (preg_match('/'.self::REGEX_UNQUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
$token .= $match[1];
} else {
// should never happen
Expand Down

0 comments on commit 2e322c7

Please sign in to comment.