Skip to content

Commit c1e4dbf

Browse files
committed
minor #12372 [Yaml] don't override internal PHP constants (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Yaml] don't override internal PHP constants | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11783 | License | MIT | Doc PR | Commits ------- 376cc03 don't override internal PHP constants
2 parents 8dbeefa + 3aa9213 commit c1e4dbf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Fragment/HIncludeFragmentRenderer.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
namespace Symfony\Component\HttpKernel\Fragment;
1313

14-
if (!defined('ENT_SUBSTITUTE')) {
15-
define('ENT_SUBSTITUTE', 8);
16-
}
17-
1814
use Symfony\Component\HttpFoundation\Request;
1915
use Symfony\Component\HttpFoundation\Response;
2016
use Symfony\Component\Templating\EngineInterface;
@@ -111,11 +107,16 @@ public function render($uri, Request $request, array $options = array())
111107
}
112108
$renderedAttributes = '';
113109
if (count($attributes) > 0) {
110+
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
111+
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
112+
} else {
113+
$flags = ENT_QUOTES;
114+
}
114115
foreach ($attributes as $attribute => $value) {
115116
$renderedAttributes .= sprintf(
116117
' %s="%s"',
117-
htmlspecialchars($attribute, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false),
118-
htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false)
118+
htmlspecialchars($attribute, $flags, $this->charset, false),
119+
htmlspecialchars($value, $flags, $this->charset, false)
119120
);
120121
}
121122
}

0 commit comments

Comments
 (0)