Skip to content

Commit

Permalink
removed Filters::$xml
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 20, 2023
1 parent b7128c6 commit af9cf23
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Essential/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,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
4 changes: 0 additions & 4 deletions tests/filters/breaklines.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,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 af9cf23

Please sign in to comment.