Skip to content

Commit 0b17448

Browse files
Merge branch '3.4' into 4.3
* 3.4: [Dotenv] allow LF in single-quoted strings [Yaml] Throw exception for tagged invalid inline elements
2 parents 41e1635 + 471ca8e commit 0b17448

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Inline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ public static function parse(string $value = null, int $flags = 0, array $refere
9494
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
9595
}
9696

97-
if (null !== $tag && '' !== $tag) {
98-
return new TaggedValue($tag, $result);
99-
}
100-
10197
// some comments are allowed at the end
10298
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
10399
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
104100
}
105101

102+
if (null !== $tag && '' !== $tag) {
103+
return new TaggedValue($tag, $result);
104+
}
105+
106106
return $result;
107107
} finally {
108108
if (isset($mbEncoding)) {

Tests/InlineTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ public function testParseInvalidSequenceShouldThrowException()
167167
Inline::parse('{ foo: bar } bar');
168168
}
169169

170+
public function testParseInvalidTaggedSequenceShouldThrowException()
171+
{
172+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
173+
Inline::parse('!foo { bar: baz } qux', Yaml::PARSE_CUSTOM_TAGS);
174+
}
175+
170176
public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
171177
{
172178
$value = "'don''t do somthin'' like that'";

0 commit comments

Comments
 (0)