Skip to content

Commit 6bb881b

Browse files
committed
Merge branch '2.2' into 2.3
* 2.2: [Locale] added support for the position argument to NumberFormatter::parse() [Locale] added some more stubs for the number formatter [Yaml] fixed typo [Yaml] fixed a test on PHP < 5.4 [DomCrawler]Crawler guess charset from html fixed PHP 5.3 compatibility [Yaml] reverted previous merge partially (refs #8897) [Security] remove unused logger [Security] fix typo [Yaml] Fixed filename in the ParseException message Conflicts: src/Symfony/Component/Console/Input/InputDefinition.php src/Symfony/Component/Locale/Stub/StubNumberFormatter.php src/Symfony/Component/Locale/Tests/Stub/StubNumberFormatterTest.php
2 parents 1443b6c + bb697b6 commit 6bb881b

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Exception/ParseException.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
namespace Symfony\Component\Yaml\Exception;
1313

14+
if (!defined('JSON_UNESCAPED_UNICODE')) {
15+
define('JSON_UNESCAPED_SLASHES', 64);
16+
define('JSON_UNESCAPED_UNICODE', 256);
17+
}
18+
1419
/**
1520
* Exception class thrown when an error occurs during parsing.
1621
*
@@ -125,7 +130,7 @@ private function updateRepr()
125130
}
126131

127132
if (null !== $this->parsedFile) {
128-
$this->message .= sprintf(' in %s', json_encode($this->parsedFile));
133+
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
129134
}
130135

131136
if ($this->parsedLine >= 0) {

Tests/ParseExceptionTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Yaml\Tests;
13+
14+
use Symfony\Component\Yaml\Exception\ParseException;
15+
use Symfony\Component\Yaml\Yaml;
16+
17+
class ParseExceptionTest extends \PHPUnit_Framework_TestCase
18+
{
19+
public function testGetMessage()
20+
{
21+
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
22+
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
23+
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
24+
} else {
25+
$message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
26+
}
27+
28+
$this->assertEquals($message, $exception->getMessage());
29+
}
30+
}

0 commit comments

Comments
 (0)