Changeset 31267
- Timestamp:
- 10/28/10 15:00:09 (3 years ago)
- Files:
-
- branches/2.0/autoload.php.dist (modified) (1 diff)
- branches/2.0/install_vendors.sh (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Engine.php (modified) (4 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/EngineTest.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Command/BuildCommand.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Command/BuildModelCommand.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Command/BuildSqlCommand.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Command/Phing.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Command/PhingCommand.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/DependencyInjection/PropelExtension.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Logger/PropelLogger.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/PropelBundle.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/README (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Resources/config/propel.xml (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Tests/DependencyInjection/PropelExtensionTest.php (deleted)
- branches/2.0/src/Symfony/Bundle/PropelBundle/Tests/TestCase.php (deleted)
- branches/2.0/src/Symfony/Bundle/TwigBundle/Extension/FormExtension.php (modified) (5 diffs)
- branches/2.0/src/Symfony/Component/OutputEscaper/ArrayDecorator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/OutputEscaper/Escaper.php (modified) (5 diffs)
- branches/2.0/update_vendors.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/autoload.php.dist
r31147 r31267 21 21 )); 22 22 $loader->register(); 23 24 // needed for code coverage25 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 28 28 git clone git://github.com/doctrine/mongodb-odm.git doctrine-mongodb 29 29 30 # Propel31 svn co http://svn.propelorm.org/branches/1.5/ propel32 33 # Phing34 svn co http://svn.phing.info/tags/2.3.3 phing35 36 30 # Swiftmailer 37 31 git clone git://github.com/swiftmailer/swiftmailer.git swiftmailer branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php
r31229 r31267 50 50 'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php'), 51 51 array( 52 'exception' => new SafeDecorator($exception),52 'exception' => $exception, 53 53 'logger' => $logger, 54 54 'currentContent' => $currentContent, branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php
r31030 r31267 9 9 </div> 10 10 <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> 12 12 <h2><strong><?php echo $exception->getStatusCode() ?></strong> <?php echo $exception->getStatusText() ?> - <?php echo $exception->getClass() ?></h2> 13 13 branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php
r31030 r31267 3 3 <head> 4 4 <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> 6 6 <style type="text/css"> 7 7 html { background: #eee } branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php
r31030 r31267 3 3 <h3> 4 4 <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()) ?> 6 6 <a href="#" onclick="toggle('traces_<?php echo $position ?>', 'traces'); return false;">»</a><br /> 7 7 </h3> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Engine.php
r31266 r31267 28 28 protected $container; 29 29 protected $escaper; 30 protected $level;31 30 32 31 /** … … 40 39 public function __construct(ContainerInterface $container, LoaderInterface $loader, array $renderers = array(), $escaper = false) 41 40 { 42 $this->level = 0;43 41 $this->container = $container; 44 42 $this->escaper = $escaper; 45 43 46 parent::__construct($loader );44 parent::__construct($loader, $renderers); 47 45 48 46 foreach ($this->container->findTaggedServiceIds('templating.renderer') as $id => $attributes) { … … 62 60 public function render($name, array $parameters = array()) 63 61 { 64 ++$this->level;65 66 62 list(, $options) = $this->splitTemplateName($name); 67 63 … … 74 70 75 71 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); 80 73 } 81 74 82 $content = parent::render($name, $parameters); 83 84 --$this->level; 85 86 return $content; 75 return parent::render($name, $parameters); 87 76 } 88 77 branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/EngineTest.php
r31229 r31267 14 14 use Symfony\Bundle\FrameworkBundle\Tests\TestCase; 15 15 use Symfony\Bundle\FrameworkBundle\Templating\Engine; 16 use Symfony\Component\Templating\Storage\StringStorage; 17 use Symfony\Component\Templating\Storage\Storage; 18 use Symfony\Component\Templating\Renderer\PhpRenderer; 19 use Symfony\Component\OutputEscaper\Escaper; 20 21 // simulate the rendering of another controller 22 function foo($engine) 23 { 24 return $engine->render('FooBundle:Foo:tpl1.php', array('foo' => 'foo <br />')); 25 } 16 26 17 27 class EngineTest extends TestCase 18 28 { 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 <br />', $engine->render('FooBundle:Foo:tpl1.php', array('foo' => 'foo <br />'))); 53 $this->assertEquals('foo <br />', $engine->render('FooBundle:Foo:tpl1.php', array('foo' => 'foo <br />'))); 54 55 $this->assertEquals('foo <br />foo <br />', $engine->render('FooBundle:Foo:tpl2.php', array('foo' => 'foo <br />'))); 56 $this->assertEquals('foo <br />foo <br />', $engine->render('FooBundle:Foo:tpl3.php', array('foo' => 'foo <br />'))); 57 $this->assertEquals('foo <br />foo <br />', $engine->render('FooBundle:Foo:tpl4.php', array('foo' => 'foo <br />'))); 58 } 59 19 60 /** 20 61 * @dataProvider getSplitTemplateNameTests branches/2.0/src/Symfony/Bundle/TwigBundle/Extension/FormExtension.php
r31147 r31267 49 49 { 50 50 $this->environment = $environment; 51 52 $this->templates = $this->resolveResources($this->resources);53 51 } 54 52 … … 95 93 public function render(FieldInterface $field, array $attributes = array()) 96 94 { 95 if (null === $this->templates) { 96 $this->templates = $this->resolveResources($this->resources); 97 } 98 97 99 if ($field instanceof Form || get_class($field) === 'Symfony\Component\Form\FieldGroup') { 98 100 return $this->templates['group']->getBlock('group', array( … … 117 119 public function renderHidden(FieldGroupInterface $form) 118 120 { 121 if (null === $this->templates) { 122 $this->templates = $this->resolveResources($this->resources); 123 } 124 119 125 return $this->templates['hidden']->getBlock('hidden', array( 120 126 'fields' => $form->getHiddenFields() … … 124 130 public function renderErrors($formOrField) 125 131 { 132 if (null === $this->templates) { 133 $this->templates = $this->resolveResources($this->resources); 134 } 135 126 136 return $this->templates['errors']->getBlock('errors', array( 127 137 'errors' => $formOrField->getErrors() … … 131 141 public function renderLabel(FieldInterface $field, $label = null, array $attributes = array()) 132 142 { 143 if (null === $this->templates) { 144 $this->templates = $this->resolveResources($this->resources); 145 } 146 133 147 return $this->templates['label']->getBlock('label', array( 134 148 'id' => $field->getId(), branches/2.0/src/Symfony/Component/OutputEscaper/ArrayDecorator.php
r31266 r31267 26 26 * @var int 27 27 */ 28 private $count ;28 private $count = 0; 29 29 30 30 /** branches/2.0/src/Symfony/Component/OutputEscaper/Escaper.php
r31266 r31267 207 207 * Adds a named escaper. 208 208 * 209 * Warning: An escaper must be able to deal with 210 * double-escaping correctly. 211 * 209 212 * @param string $name The escaper name 210 213 * @param mixed $escaper A PHP callable … … 263 266 // Numbers and boolean values get turned into strings which can cause problems 264 267 // 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; 266 269 }, 267 270 … … 277 280 // Numbers and boolean values get turned into strings which can cause problems 278 281 // 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; 280 283 }, 281 284 … … 295 298 'js' => 296 299 /** 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 304 302 * 305 303 * @param string $value the value to escape … … 308 306 function ($value) 309 307 { 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; 324 336 }, 325 337 ); 326 338 } 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 } 327 350 } branches/2.0/update_vendors.sh
r31057 r31267 21 21 cd $CURRENT/doctrine-mongodb && git pull 22 22 23 # Propel24 cd $CURRENT/propel && svn up25 26 # Phing27 cd $CURRENT/phing && svn up28 29 23 # Swiftmailer 30 24 cd $CURRENT/swiftmailer && git pull