Skip to content

Commit

Permalink
removed Filters::$xml
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 9, 2024
1 parent 0f54a9a commit 5175d38
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Essential/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public static function dataStream(string $data, ?string $type = null): string
public static function breaklines(string|Stringable|null $s): Html
{
$s = htmlspecialchars((string) $s, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8');
return new Html(nl2br($s, Latte\Runtime\Filters::$xml));
return new Html(nl2br($s, false));
}


Expand Down
3 changes: 0 additions & 3 deletions src/Latte/Runtime/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class Filters
/** @deprecated */
public static string $dateFormat = "j.\u{a0}n.\u{a0}Y";

/** @internal use XML syntax? */
public static bool $xml = false;


/**
* Escapes string for use everywhere inside HTML (except for comments).
Expand Down
2 changes: 0 additions & 2 deletions src/Latte/Runtime/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public function render(?string $block = null): void
$this->parentName = ($this->global->coreParentFinder)($this);
}

Filters::$xml = static::ContentType === Latte\ContentType::Xml;

if ($this->referenceType === 'import') {
if ($this->parentName) {
throw new Latte\RuntimeException('Imported template cannot use {extends} or {layout}, use {import}');
Expand Down
5 changes: 0 additions & 5 deletions tests/filters/breaklines.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
declare(strict_types=1);

use Latte\Essential\Filters;
use Latte\Runtime;
use Latte\Runtime\Html;
use Tester\Assert;

Expand All @@ -16,10 +15,6 @@ require __DIR__ . '/../bootstrap.php';

$input = "Hello\nmy\r\nfriend\n\r";

Runtime\Filters::$xml = true;
Assert::equal(new Html("Hello<br />\nmy<br />\r\nfriend<br />\n\r"), Filters::breaklines($input));

Runtime\Filters::$xml = false;
Assert::equal(new Html("Hello<br>\nmy<br>\r\nfriend<br>\n\r"), Filters::breaklines($input));

Assert::equal(new Html("&lt;&gt;<br>\n&amp;"), Filters::breaklines("<>\n&"));
Expand Down

0 comments on commit 5175d38

Please sign in to comment.