Updated vendors

This commit is contained in:
Polonkai Gergely
2012-07-23 08:07:07 +02:00
parent b82b4ffd34
commit b9e6708ffd
110 changed files with 1066 additions and 1243 deletions

View File

@@ -1,5 +1,10 @@
* 1.9.1 (2012-XX-XX)
* 1.9.2 (2012-XX-XX)
* n/a
* 1.9.1 (2012-07-22)
* optimized macro calls when auto-escaping is on
* fixed wrong parent class for Twig_Function_Node
* made Twig_Loader_Chain more explicit about problems

View File

@@ -15,7 +15,7 @@
#ifndef PHP_TWIG_H
#define PHP_TWIG_H
#define PHP_TWIG_VERSION "1.9.1-DEV"
#define PHP_TWIG_VERSION "1.9.2-DEV"
#include "php.h"

View File

@@ -17,7 +17,7 @@
*/
class Twig_Environment
{
const VERSION = '1.9.1-DEV';
const VERSION = '1.9.2-DEV';
protected $charset;
protected $loader;

View File

@@ -22,6 +22,7 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface
protected $safeAnalysis;
protected $traverser;
protected $defaultStrategy = false;
protected $safeVars = array();
public function __construct()
{
@@ -42,10 +43,13 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface
if ($env->hasExtension('escaper') && $defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename'))) {
$this->defaultStrategy = $defaultStrategy;
}
$this->safeVars = array();
} elseif ($node instanceof Twig_Node_AutoEscape) {
$this->statusStack[] = $node->getAttribute('value');
} elseif ($node instanceof Twig_Node_Block) {
$this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
} elseif ($node instanceof Twig_Node_Import) {
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
}
return $node;
@@ -63,6 +67,7 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface
{
if ($node instanceof Twig_Node_Module) {
$this->defaultStrategy = false;
$this->safeVars = array();
} elseif ($node instanceof Twig_Node_Expression_Filter) {
return $this->preEscapeFilterNode($node, $env);
} elseif ($node instanceof Twig_Node_Print) {
@@ -129,6 +134,9 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface
if (null === $this->traverser) {
$this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis));
}
$this->safeAnalysis->setSafeVars($this->safeVars);
$this->traverser->traverse($expression);
$safe = $this->safeAnalysis->getSafe($expression);
}

View File

@@ -3,6 +3,12 @@
class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface
{
protected $data = array();
protected $safeVars = array();
public function setSafeVars($safeVars)
{
$this->safeVars = $safeVars;
}
public function getSafe(Twig_NodeInterface $node)
{
@@ -85,6 +91,14 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface
} else {
$this->setSafe($node, array());
}
} elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) {
$name = $node->getNode('node')->getAttribute('name');
// attributes on template instances are safe
if ('_self' == $name || in_array($name, $this->safeVars)) {
$this->setSafe($node, array('all'));
} else {
$this->setSafe($node, array());
}
} else {
$this->setSafe($node, array());
}

View File

@@ -424,7 +424,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
$ret = call_user_func_array(array($object, $method), $arguments);
// hack to be removed when macro calls are refactored
// useful when calling a template method from a template
// this is not supported but unfortunately heavily used in the Symfony profiler
if ($object instanceof Twig_TemplateInterface) {
return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset());
}