8000 [OutputEscaper] added SafeDecoratorInterface · brtriver/symfony@6aa190b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6aa190b

Browse files
committed
[OutputEscaper] added SafeDecoratorInterface
1 parent 7650dd7 commit 6aa190b

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/Symfony/Component/OutputEscaper/Escaper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ static public function escape($escaper, $value)
118118
return $copy;
119119
}
120120

121-
if (self::isClassMarkedAsSafe(get_class($value))) {
122-
// the class or one of its children is marked as safe
123-
// return the unescaped object
124-
return $value;
125-
}
126-
127121
if ($value instanceof SafeDecorator) {
128122
// do not escape objects marked as safe
129123
// return the original object
130124
return $value->getValue();
131125
}
132126

127+
if (self::isClassMarkedAsSafe(get_class($value)) || $value instanceof SafeDecoratorInterface) {
128+
// the class or one of its children is marked as safe
129+
// return the unescaped object
130+
return $value;
131+
}
132+
133133
if ($value instanceof \Traversable) {
134134
return new IteratorDecorator($escaper, $value);
135135
}

src/Symfony/Component/OutputEscaper/SafeDecorator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
1818
*/
19-
class SafeDecorator extends \ArrayIterator
19+
class SafeDecorator extends \ArrayIterator implements SafeDecoratorInterface
2020
{
2121
protected $value;
2222

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Symfony\Component\OutputEscaper;
4+
5+
/*
6+
* This file is part of the Symfony package.
7+
*
8+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
/**
15+
* Marks a class as being safe for output.
16+
*
17+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
18+
*/
19+
interface SafeDecoratorInterface
20+
{
21+
}

0 commit comments

Comments
 (0)
0