Skip to content

Commit 5d62c4f

Browse files
Merge branch '4.4' into 5.1
* 4.4: Dont allow unserializing classes with a destructor Dont allow unserializing classes with a destructor - 4.4 [Cache] fix possible collision when writing tmp file in filesystem adapter a colon followed by spaces exclusively separates mapping keys and values Contracts: Remove ellipsis fix handling float-like key attribute values Fix missing BCC recipients in SES bridge
2 parents 667e2f9 + dd3f776 commit 5d62c4f

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ private function doParse(string $value, int $flags)
203203
array_pop($this->refsBeingParsed);
204204
}
205205
} elseif (
206-
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
206+
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:( ++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
207207
&& (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))
208208
) {
209209
if ($context && 'sequence' == $context) {

Tests/InlineTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,4 +915,21 @@ public function quotedExclamationMarkProvider()
915915
[['!'], '! ["!"]'],
916916
];
917917
}
918+
919+
/**
920+
* @dataProvider ideographicSpaceProvider
921+
*/
922+
public function testParseIdeographicSpace(string $yaml, string $expected)
923+
{
924+
$this->assertSame($expected, Inline::parse($yaml));
925+
}
926+
927+
public function ideographicSpaceProvider(): array
928+
{
929+
return [
930+
["\u{3000}", ' '],
931+
["'\u{3000}'", ' '],
932+
["'a b'", 'a b'],
933+
];
934+
}
918935
}

Tests/ParserTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,22 @@ public function testParsingMultipleDocuments()
27322732
// (before, there was no \n after row2)
27332733
$this->assertSame(['a' => ['b' => "row\nrow2\n"], 'c' => 'd'], $this->parser->parse($longDocument));
27342734
}
2735+
2736+
public function testParseIdeographicSpaces()
2737+
{
2738+
$expected = <<<YAML
2739+
unquoted: \u{3000}
2740+
quoted: '\u{3000}'
2741+
within_string: 'a b'
2742+
regular_space: 'a b'
2743+
YAML;
2744+
$this->assertSame([
2745+
'unquoted' => ' ',
2746+
'quoted' => ' ',
2747+
'within_string' => 'a b',
2748+
'regular_space' => 'a b',
2749+
], $this->parser->parse($expected));
2750+
}
27352751
}
27362752

27372753
class B

0 commit comments

Comments
 (0)