mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
Fix custom escaper null values
This commit is contained in:
committed by
Fabien Potencier
parent
79249fc8c9
commit
6f84981ae6
@@ -1,3 +1,7 @@
|
||||
* 1.22.3 (2015-XX-XX)
|
||||
|
||||
* changed template cache names to take into account the Twig C extension
|
||||
|
||||
* 1.22.2 (2015-09-22)
|
||||
|
||||
* fixed a race condition in template loading
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#ifndef PHP_TWIG_H
|
||||
#define PHP_TWIG_H
|
||||
|
||||
#define PHP_TWIG_VERSION "1.22.2"
|
||||
#define PHP_TWIG_VERSION "1.22.3-DEV"
|
||||
|
||||
#include "php.h"
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
class Twig_Environment
|
||||
{
|
||||
const VERSION = '1.22.2';
|
||||
const VERSION = '1.22.3-DEV';
|
||||
|
||||
protected $charset;
|
||||
protected $loader;
|
||||
@@ -291,6 +291,12 @@ class Twig_Environment
|
||||
/**
|
||||
* Gets the template class associated with the given string.
|
||||
*
|
||||
* The generated template class is based on the following parameters:
|
||||
*
|
||||
* * The cache key for the given template;
|
||||
* * The currently enabled extensions;
|
||||
* * Whether the Twig C extension is available or not.
|
||||
*
|
||||
* @param string $name The name for which to calculate the template class name
|
||||
* @param int $index The index if it is an embedded template
|
||||
*
|
||||
@@ -300,6 +306,10 @@ class Twig_Environment
|
||||
{
|
||||
$key = $this->getLoader()->getCacheKey($name).'__'.implode('__', array_keys($this->extensions));
|
||||
|
||||
if (function_exists('twig_template_get_attributes')) {
|
||||
$key .= '__cext';
|
||||
}
|
||||
|
||||
return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,7 +1021,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
||||
if (!is_string($string)) {
|
||||
if (is_object($string) && method_exists($string, '__toString')) {
|
||||
$string = (string) $string;
|
||||
} else {
|
||||
} elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
$twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
|
||||
|
||||
$this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
|
||||
$this->assertEquals('UTF-8', twig_escape_filter($twig, null, 'foo'));
|
||||
$this->assertEquals('42UTF-8', twig_escape_filter($twig, 42, 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user