Skip to content

Commit

Permalink
make double encoding the default like htmlspecialchars
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 29, 2018
1 parent 5923416 commit 7c82ff4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ function dd(...$args)
* @param bool $doubleEncode
* @return string
*/
function e($value, $doubleEncode = false)
function e($value, $doubleEncode = true)
{
if ($value instanceof Htmlable) {
return $value->toHtml();
Expand Down
14 changes: 12 additions & 2 deletions src/Illuminate/View/Compilers/BladeCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,22 @@ public function setEchoFormat($format)
}

/**
* Set the echo format to double encode entities.
* Set the "echo" format to double encode entities.
*
* @return void
*/
public function doubleEncode()
public function withDoubleEncoding()
{
$this->setEchoFormat('e(%s, true)');
}

/**
* Set the "echo" format to not double encode entities.
*
* @return void
*/
public function withoutDoubleEncoding()
{
$this->setEchoFormat('e(%s, false)');
}
}

0 comments on commit 7c82ff4

Please sign in to comment.