Skip to content

Commit

Permalink
[Yaml] ensures that the mb_internal_encoding is reset to its initial …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
Jörn Lang committed Dec 11, 2018
1 parent 9b7b862 commit 56ab129
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -110,35 +110,37 @@ public static function parse($value, $flags = 0, $references = array())
mb_internal_encoding('ASCII');
}

$i = 0;
$tag = self::parseTag($value, $i, $flags);
switch ($value[$i]) {
case '[':
$result = self::parseSequence($value, $flags, $i, $references);
++$i;
break;
case '{':
$result = self::parseMapping($value, $flags, $i, $references);
++$i;
break;
default:
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
}
try {
$i = 0;
$tag = self::parseTag($value, $i, $flags);
switch ($value[$i]) {
case '[':
$result = self::parseSequence($value, $flags, $i, $references);
++$i;
break;
case '{':
$result = self::parseMapping($value, $flags, $i, $references);
++$i;
break;
default:
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
}

if (null !== $tag) {
return new TaggedValue($tag, $result);
}
if (null !== $tag) {
return new TaggedValue($tag, $result);
}

// some comments are allowed at the end
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
// some comments are allowed at the end
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}

if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
return $result;
} finally {
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
}

return $result;
}

/**
Expand Down

0 comments on commit 56ab129

Please sign in to comment.