Development

Changeset 10833

You must first sign up to be able to contribute.

Changeset 10833

Show
Ignore:
Timestamp:
08/13/08 13:33:13 (6 years ago)
Author:
fabien
Message:

[1.0, 1.1, 1.2] fixed % causes escaping of single quotes in app.yml in some circumstances (closes #2849)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/util/sfToolkit.class.php

    r10719 r10833  
    361361  public static function replaceConstants($value) 
    362362  { 
    363     return is_string($value) ? preg_replace('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value; 
     363    return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value; 
    364364  } 
    365365 
  • branches/1.0/test/unit/util/sfToolkitTest.php

    r10515 r10833  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(72, new lime_output_color()); 
     13$t = new lime_test(75, new lime_output_color()); 
    1414 
    1515// ::stringToArray() 
     
    8282sfConfig::set('bar', null); 
    8383$t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a  constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null'); 
     84$t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
     85$t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
     86$t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
    8487 
    8588// ::isPathAbsolute() 
  • branches/1.1/lib/util/sfToolkit.class.php

    r10719 r10833  
    382382  public static function replaceConstants($value) 
    383383  { 
    384     return is_string($value) ? preg_replace('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value; 
     384    return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value; 
    385385  } 
    386386 
  • branches/1.1/test/unit/util/sfToolkitTest.php

    r10516 r10833  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(104, new lime_output_color()); 
     13$t = new lime_test(107, new lime_output_color()); 
    1414 
    1515// ::stringToArray() 
     
    8282sfConfig::set('bar', null); 
    8383$t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a  constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null'); 
     84$t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
     85$t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
     86$t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
    8487 
    8588// ::isPathAbsolute() 
  • branches/1.2/lib/util/sfToolkit.class.php

    r10719 r10833  
    382382  public static function replaceConstants($value) 
    383383  { 
    384     return is_string($value) ? preg_replace('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value; 
     384    return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value; 
    385385  } 
    386386 
  • branches/1.2/test/unit/util/sfToolkitTest.php

    r10518 r10833  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(104, new lime_output_color()); 
     13$t = new lime_test(107, new lime_output_color()); 
    1414 
    1515// ::stringToArray() 
     
    8282sfConfig::set('bar', null); 
    8383$t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a  constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null'); 
     84$t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
     85$t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
     86$t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 
    8487 
    8588// ::isPathAbsolute()