Development

Changeset 31267

You must first sign up to be able to contribute.

Changeset 31267

Show
Ignore:
Timestamp:
10/28/10 15:00:09 (3 years ago)
Author:
fabien
Message:

Merge branch 'master' of git://github.com/symfony/symfony

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.0/autoload.php.dist

    r31147 r31267  
    2121)); 
    2222$loader->register(); 
    23  
    24 // needed for code coverage 
    25 require_once __DIR__.'/vendor/propel/runtime/lib/Propel.php'; 
    26 set_include_path( 
    27     __DIR__.'/vendor/phing/classes'.PATH_SEPARATOR. 
    28     __DIR__.'/vendor/propel/runtime/lib'.PATH_SEPARATOR. 
    29     get_include_path() 
    30 ); 
  • branches/2.0/install_vendors.sh

    r31057 r31267  
    2828git clone git://github.com/doctrine/mongodb-odm.git doctrine-mongodb 
    2929 
    30 # Propel 
    31 svn co http://svn.propelorm.org/branches/1.5/ propel 
    32  
    33 # Phing 
    34 svn co http://svn.phing.info/tags/2.3.3 phing 
    35  
    3630# Swiftmailer 
    3731git clone git://github.com/swiftmailer/swiftmailer.git swiftmailer 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php

    r31229 r31267  
    5050            'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php'), 
    5151            array( 
    52                 'exception'      => new SafeDecorator($exception)
     52                'exception'      => $exception
    5353                'logger'         => $logger, 
    5454                'currentContent' => $currentContent, 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php

    r31030 r31267  
    99        </div> 
    1010        <div style="float: left; width: 600px"> 
    11             <h1><?php echo $view->get('code')->formatFileFromText(str_replace("\n", '<br />', htmlspecialchars($exception->getMessage(), ENT_QUOTES, $view->getCharset()))) ?></h1> 
     11            <h1><?php echo $view->get('code')->formatFileFromText(str_replace("\n", '<br />', $exception->getMessage())) ?></h1> 
    1212            <h2><strong><?php echo $exception->getStatusCode() ?></strong> <?php echo $exception->getStatusText() ?> - <?php echo $exception->getClass() ?></h2> 
    1313 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php

    r31030 r31267  
    33    <head> 
    44        <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $view->getCharset() ?>"/> 
    5         <title><?php echo htmlspecialchars($exception->getMessage(), ENT_QUOTES, $view->getCharset()) ?> (<?php echo $exception->getStatusCode() ?> <?php echo $exception->getStatusText() ?>)</title> 
     5        <title><?php echo $exception->getMessage() ?> (<?php echo $exception->getStatusCode() ?> <?php echo $exception->getStatusText() ?>)</title> 
    66        <style type="text/css"> 
    77            html { background: #eee } 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php

    r31030 r31267  
    33        <h3> 
    44            <span><?php echo $count - $position + 1 ?>/<?php echo $count + 1 ?></span> 
    5             <?php echo $view->get('code')->abbrClass($exception->getClass()) ?>: <?php echo str_replace("\n", '<br />', htmlspecialchars($exception->getMessage(), ENT_QUOTES, $view->getCharset())) ?> 
     5            <?php echo $view->get('code')->abbrClass($exception->getClass()) ?>: <?php echo str_replace("\n", '<br />', $exception->getMessage()) ?> 
    66            <a href="#" onclick="toggle('traces_<?php echo $position ?>', 'traces'); return false;">&raquo;</a><br /> 
    77        </h3> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Engine.php

    r31266 r31267  
    2828    protected $container; 
    2929    protected $escaper; 
    30     protected $level; 
    3130 
    3231    /** 
     
    4039    public function __construct(ContainerInterface $container, LoaderInterface $loader, array $renderers = array(), $escaper = false) 
    4140    { 
    42         $this->level = 0; 
    4341        $this->container = $container; 
    4442        $this->escaper = $escaper; 
    4543 
    46         parent::__construct($loader); 
     44        parent::__construct($loader, $renderers); 
    4745 
    4846        foreach ($this->container->findTaggedServiceIds('templating.renderer') as $id => $attributes) { 
     
    6260    public function render($name, array $parameters = array()) 
    6361    { 
    64         ++$this->level; 
    65  
    6662        list(, $options) = $this->splitTemplateName($name); 
    6763 
     
    7470 
    7571        if ('php' === $renderer) { 
    76             // escape only once 
    77             if (1 === $this->level && !isset($parameters['_data'])) { 
    78                 $parameters = $this->escapeParameters($parameters); 
    79             } 
     72            $parameters = $this->escapeParameters($parameters); 
    8073        } 
    8174 
    82         $content = parent::render($name, $parameters); 
    83  
    84         --$this->level; 
    85  
    86         return $content; 
     75        return parent::render($name, $parameters); 
    8776    } 
    8877 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/EngineTest.php

    r31229 r31267  
    1414use Symfony\Bundle\FrameworkBundle\Tests\TestCase; 
    1515use Symfony\Bundle\FrameworkBundle\Templating\Engine; 
     16use Symfony\Component\Templating\Storage\StringStorage; 
     17use Symfony\Component\Templating\Storage\Storage; 
     18use Symfony\Component\Templating\Renderer\PhpRenderer; 
     19use Symfony\Component\OutputEscaper\Escaper; 
     20 
     21// simulate the rendering of another controller 
     22function foo($engine) 
     23{ 
     24    return $engine->render('FooBundle:Foo:tpl1.php', array('foo' => 'foo <br />')); 
     25} 
    1626 
    1727class EngineTest extends TestCase 
    1828{ 
     29    public function testRenderEscaping() 
     30    { 
     31        $templates = array( 
     32            'tpl1'  => '<?php echo $foo ?>', 
     33            'tpl2'  => '<?php echo $foo.$view->render("FooBundle:Foo:tpl1.php", array("foo" => $foo)) ?>', 
     34            'tpl3'  => '<?php echo $foo.$view->render("FooBundle:Foo:tpl1.php", array("foo" => "foo <br />")) ?>', 
     35            'tpl4'  => '<?php echo $foo.Symfony\Bundle\FrameworkBundle\Tests\Templating\foo($view) ?>', 
     36        ); 
     37 
     38        $loader = $this->getMock('Symfony\Component\Templating\Loader\LoaderInterface'); 
     39        $loader->expects($this->exactly(4)) 
     40            ->method('load') 
     41            ->with($this->anything(), $this->anything()) 
     42            ->will($this->onConsecutiveCalls( 
     43                new StringStorage($templates['tpl1']), 
     44                new StringStorage($templates['tpl2']), 
     45                new StringStorage($templates['tpl3']), 
     46                new StringStorage($templates['tpl4']) 
     47            )) 
     48        ; 
     49 
     50        $engine = new Engine($this->getContainerMock(), $loader, array('php' => new PhpRenderer()), 'htmlspecialchars'); 
     51 
     52        $this->assertEquals('foo &lt;br /&gt;', $engine->render('FooBundle:Foo:tpl1.php', array('foo' => 'foo <br />'))); 
     53        $this->assertEquals('foo &lt;br /&gt;', $engine->render('FooBundle:Foo:tpl1.php', array('foo' => 'foo <br />'))); 
     54 
     55        $this->assertEquals('foo &lt;br /&gt;foo &lt;br /&gt;', $engine->render('FooBundle:Foo:tpl2.php', array('foo' => 'foo <br />'))); 
     56        $this->assertEquals('foo &lt;br /&gt;foo &lt;br /&gt;', $engine->render('FooBundle:Foo:tpl3.php', array('foo' => 'foo <br />'))); 
     57        $this->assertEquals('foo &lt;br /&gt;foo &lt;br /&gt;', $engine->render('FooBundle:Foo:tpl4.php', array('foo' => 'foo <br />'))); 
     58    } 
     59 
    1960    /** 
    2061     * @dataProvider getSplitTemplateNameTests 
  • branches/2.0/src/Symfony/Bundle/TwigBundle/Extension/FormExtension.php

    r31147 r31267  
    4949    { 
    5050        $this->environment = $environment; 
    51  
    52         $this->templates = $this->resolveResources($this->resources); 
    5351    } 
    5452 
     
    9593    public function render(FieldInterface $field, array $attributes = array()) 
    9694    { 
     95        if (null === $this->templates) { 
     96            $this->templates = $this->resolveResources($this->resources); 
     97        } 
     98 
    9799        if ($field instanceof Form || get_class($field) === 'Symfony\Component\Form\FieldGroup') { 
    98100            return $this->templates['group']->getBlock('group', array( 
     
    117119    public function renderHidden(FieldGroupInterface $form) 
    118120    { 
     121        if (null === $this->templates) { 
     122            $this->templates = $this->resolveResources($this->resources); 
     123        } 
     124 
    119125        return $this->templates['hidden']->getBlock('hidden', array( 
    120126            'fields' => $form->getHiddenFields() 
     
    124130    public function renderErrors($formOrField) 
    125131    { 
     132        if (null === $this->templates) { 
     133            $this->templates = $this->resolveResources($this->resources); 
     134        } 
     135 
    126136        return $this->templates['errors']->getBlock('errors', array( 
    127137            'errors' => $formOrField->getErrors() 
     
    131141    public function renderLabel(FieldInterface $field, $label = null, array $attributes = array()) 
    132142    { 
     143        if (null === $this->templates) { 
     144            $this->templates = $this->resolveResources($this->resources); 
     145        } 
     146 
    133147        return $this->templates['label']->getBlock('label', array( 
    134148            'id'         => $field->getId(), 
  • branches/2.0/src/Symfony/Component/OutputEscaper/ArrayDecorator.php

    r31266 r31267  
    2626     * @var int 
    2727     */ 
    28     private $count
     28    private $count = 0
    2929 
    3030    /** 
  • branches/2.0/src/Symfony/Component/OutputEscaper/Escaper.php

    r31266 r31267  
    207207     * Adds a named escaper. 
    208208     * 
     209     * Warning: An escaper must be able to deal with 
     210     * double-escaping correctly. 
     211     * 
    209212     * @param string $name    The escaper name 
    210213     * @param mixed  $escaper A PHP callable 
     
    263266                    // Numbers and boolean values get turned into strings which can cause problems 
    264267                    // with type comparisons (e.g. === or is_int() etc). 
    265                     return is_string($value) ? htmlspecialchars($value, ENT_QUOTES, Escaper::getCharset()) : $value; 
     268                    return is_string($value) ? htmlspecialchars($value, ENT_QUOTES, Escaper::getCharset(), false) : $value; 
    266269                }, 
    267270 
     
    277280                    // Numbers and boolean values get turned into strings which can cause problems 
    278281                    // with type comparisons (e.g. === or is_int() etc). 
    279                     return is_string($value) ? htmlentities($value, ENT_QUOTES, Escaper::getCharset()) : $value; 
     282                    return is_string($value) ? htmlentities($value, ENT_QUOTES, Escaper::getCharset(), false) : $value; 
    280283                }, 
    281284 
     
    295298            'js' => 
    296299                /** 
    297                  * A function that c-escapes a string after applying (cf. entities). The 
    298                  * assumption is that the value will be used to generate dynamic HTML in some 
    299                  * way and the safest way to prevent mishap is to assume the value should have 
    300                  * HTML entities set properly. 
    301                  * 
    302                  * The (cf. js_no_entities) method should be used to escape a string 
    303                  * that is ultimately not going to end up as text in an HTML document. 
     300                 * A function that escape all non-alphanumeric characters 
     301                 * into their \xHH or \uHHHH representations 
    304302                 * 
    305303                 * @param string $value the value to escape 
     
    308306                function ($value) 
    309307                { 
    310                     return str_replace(array("\\"  , "\n"  , "\r" , "\""  , "'"  ), array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), (is_string($value) ? htmlentities($value, ENT_QUOTES, Escaper::getCharset()) : $value)); 
    311                 }, 
    312  
    313             'js_no_entities' => 
    314                 /** 
    315                  * A function the c-escapes a string, making it suitable to be placed in a 
    316                  * JavaScript string. 
    317                  * 
    318                  * @param string $value the value to escape 
    319                  * @return string the escaped value 
    320                  */ 
    321                 function ($value) 
    322                 { 
    323                     return str_replace(array("\\"  , "\n"  , "\r" , "\""  , "'"  ), array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), $value); 
     308                    if ('UTF-8' != Escaper::getCharset()) { 
     309                        $string = Escaper::convertEncoding($string, 'UTF-8', Escaper::getCharset()); 
     310                    } 
     311 
     312                    $callback = function ($matches) 
     313                    { 
     314                        $char = $matches[0]; 
     315 
     316                        // \xHH 
     317                        if (!isset($char[1])) { 
     318                            return '\\x'.substr('00'.bin2hex($char), -2); 
     319                        } 
     320 
     321                        // \uHHHH 
     322                        $char = Escaper::convertEncoding($char, 'UTF-16BE', 'UTF-8'); 
     323 
     324                        return '\\u'.substr('0000'.bin2hex($char), -4); 
     325                    }; 
     326 
     327                    if (null === $string = preg_replace_callback('#[^\p{L}\p{N} ]#u', $callback, $string)) { 
     328                        throw new InvalidArgumentException('The string to escape is not a valid UTF-8 string.'); 
     329                    } 
     330 
     331                    if ('UTF-8' != Escaper::getCharset()) { 
     332                        $string = Escaper::convertEncoding($string, Escaper::getCharset(), 'UTF-8'); 
     333                    } 
     334 
     335                    return $string; 
    324336                }, 
    325337        ); 
    326338    } 
     339 
     340    static public function convertEncoding($string, $to, $from) 
     341    { 
     342        if (function_exists('iconv')) { 
     343            return iconv($from, $to, $string); 
     344        } elseif (function_exists('mb_convert_encoding')) { 
     345            return mb_convert_encoding($string, $to, $from); 
     346        } else { 
     347            throw new RuntimeException('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).'); 
     348        } 
     349    } 
    327350} 
  • branches/2.0/update_vendors.sh

    r31057 r31267  
    2121cd $CURRENT/doctrine-mongodb && git pull 
    2222 
    23 # Propel 
    24 cd $CURRENT/propel && svn up 
    25  
    26 # Phing 
    27 cd $CURRENT/phing && svn up 
    28  
    2923# Swiftmailer 
    3024cd $CURRENT/swiftmailer && git pull