This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component
Fabien Potencier 27100ba4eb merged branch jakzal/yamlDoubleQuotesDumperFix (PR #4320)
Commits
-------

b631073 [Yaml] Fixed double quotes escaping in Dumper.

Discussion
----------

[Yaml] Fixed double quotes escaping in Dumper

Issue #4308 is caused by Dumper::escapeWithDoubleQuotes() which uses [str_replace()](http://php.net/str_replace).

From the php docs:

> Because str_replace() replaces left to right, it might replace a previously inserted value when doing multiple replacements.

We should be very careful in deciding about the order of elements in $escapees array. I'd really appreciate if someone reviewed my fix. Tests say I didn't break anything but I'm not sure what percentage of Yaml specification is covered by tests.

Bug fix: yes
Feature addition: no
Backwards compatibility break: not that I know
Symfony2 tests pass: [![Build Status](https://secure.travis-ci.org/jakzal/symfony.png?branch=yamlDoubleQuotesDumperFix)](http://travis-ci.org/jakzal/symfony)
Fixes the following tickets: #4308

---------------------------------------------------------------------------

by travisbot at 2012-05-18T08:53:51Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1364279) (merged 5192722c into a04acc89).

---------------------------------------------------------------------------

by travisbot at 2012-05-18T23:19:49Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1371539) (merged ecaa1aab into fc3c609b).

---------------------------------------------------------------------------

by dinamic at 2012-05-19T07:35:21Z

Something is really wrong with this method. You can see clearly that multiple characters would fail proper escaping.

Here's an example:
```
$value = '\\\\"some value\n \"some quoted string\" and \'some single quotes one\'"';
var_dump(Escaper::escapeWithDoubleQuotes($value));
string(72) ""\\\"some value\n \\some quoted string\\ and 'some single quotes one'\"""
```

To begin with the backslash - in the initial value you have 2 (escaped ones), that after escaping should result in 4, not in 1 (escaped). I guess this behavior has to be verified with the importer, but imho it does not seem right.

Does anyone know why this escaping wasn't done using a regular expression in first place?

---------------------------------------------------------------------------

by clemens-tolboom at 2012-05-19T10:18:58Z

Searching for https://duckduckgo.com/?q=what+is+\xc2\x85 the table on http://stackoverflow.com/questions/6609895/efficiently-replace-bad-characters is interesting enough to decide we need way more documentation on this file.

\xc2\x85 seems to be triple dot (ellipses)
\xe2\x80\xa9 seems to be paragraph separator see http://drupal.org/node/914360#comment-3468550
2012-06-09 17:04:17 +02:00
..
BrowserKit fixed CS 2012-03-11 17:59:42 +01:00
ClassLoader [ClassLoader] Fixed state when trait_exists doesn't exists 2011-09-25 19:25:50 +02:00
Config fixed CS 2012-05-21 16:05:09 +02:00
Console fixed CS 2012-05-20 18:15:10 +02:00
CssSelector [CssSelector] ignored an optional whitespace after a combinator 2012-05-13 09:14:40 +02:00
DependencyInjection fixed CS 2012-05-20 18:15:10 +02:00
DomCrawler fixed CS 2012-05-20 18:15:10 +02:00
EventDispatcher [EventDispatcher] Fixed E_NOTICES with multiple eventnames per subscriber with mixed priorities 2012-04-12 15:56:02 +05:45
Finder fixed CS 2012-05-21 22:25:19 +02:00
Form [Form] fixed a bug that caused input date validation not to be strict when using the single_text widget with a datetime field 2012-05-28 14:41:53 +09:00
HttpFoundation fixed CS 2012-05-21 22:25:19 +02:00
HttpKernel fixed CS 2012-05-21 22:25:19 +02:00
Locale MethodNotImplementedException -> MethodArgumentValueNotImplementedException 2012-06-04 19:15:56 +02:00
Process fixed CS 2012-05-20 18:15:10 +02:00
Routing fixed CS 2012-05-20 18:15:10 +02:00
Security fixed CS 2012-05-20 18:15:10 +02:00
Serializer [Serializer] Fix XML decoding attack vector through external entities 2012-02-24 22:50:04 +01:00
Templating removed unused use statements 2011-10-29 11:56:30 +02:00
Translation Rename test file 2011-12-29 16:30:31 +01:00
Validator fixed CS 2012-05-21 16:05:09 +02:00
Yaml [Yaml] Fixed double quotes escaping in Dumper. 2012-05-19 00:23:47 +01:00