Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Console] Revert StringInput bc break from #45088
  • Loading branch information
bobthecow committed Jan 30, 2022
commit aab2f2a72940097052d0f297ed209e47a844777c
5 changes: 3 additions & 2 deletions src/Symfony/Component/Console/Input/StringInput.php
Original file line number Diff line number Diff line change
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