Development

#2849 (% causes escaping of single quotes in app.yml in some circumstances)

You must first sign up to be able to contribute.

Ticket #2849 (new defect)

Opened 6 months ago

Last modified 4 weeks ago

% causes escaping of single quotes in app.yml in some circumstances

Reported by: austin Assigned to: fabien
Priority: major Milestone: 1.2.0
Component: configuration Version: 1.1.0 RC2
Keywords: Cc:
Qualification: Design decision

Description

% causes escaping of single quotes in app.yml in some circumstances.

For example, if you define these in app.yml:

test1: test %te'st%

test2: test %te'st

Then ' will be escaped in test1, making the values:

sfConfig::get('app_test1') == test %te\'st% sfConfig::get('app_test2') == test %te'st

I discovered this while trying to set google analytics tracking codes in app.yml.

Change History

01/27/08 10:10:15 changed by Andrejs.Verza

Did you try the following?

  test1: "test %te'st%"
  test2: "test %te'st"

01/28/08 19:50:36 changed by austin

I get the same results with that.

01/28/08 21:06:45 changed by austin

I think this may be related to sfToolkit::replaceConstants being called on every value of app.yml after the yaml is parsed.

02/28/08 08:16:31 changed by austin

I have not tested it extensively, but I believe the solution to this may be to change this line in sfToolkit::replaceConstants:

return is_string($value) ? preg_replace('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value;

to:

return is_string($value) ? preg_replace('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : \'%\\1%\'', $value) : $value;

That is, changing "%\\1%"' to \'%\\1%\

preg_replace with the \e option escapes some characters, including ', in the backreference replacements. When used in the expression the way it is with double quotes, that is causing the double escaping. Using single quotes in the expression seems to fix it.

04/12/08 07:06:44 changed by austin

Is there anything I can do to help this fix be included in 1.1? Would providing a patch file of the solution above help? Are there any problems with my solution?

05/08/08 00:40:02 changed by austin

  • version changed from 1.1.0 DEV to 1.1.0 RC1.

06/11/08 22:31:23 changed by austin

  • version changed from 1.1.0 RC1 to 1.1.0 RC2.
  • milestone set to 1.1.0.

06/17/08 19:31:30 changed by dwhittle

Austin, can you submit a patch please?

06/23/08 05:46:15 changed by dwhittle

  • qualification changed from Unreviewed to Design decision.
  • milestone changed from 1.1.0 to 1.2.0.