Skip to content

Commit

Permalink
BustCacheMacro: Replace deprecated safeurl filter by checkurl
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Mar 1, 2019
1 parent 781efee commit 82195dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/BustCache/BustCacheMacro.php
Expand Up @@ -77,7 +77,7 @@ public function nodeOpened(MacroNode $node): bool
}

$node->empty = true;
$node->modifiers = '|safeurl|escape'; // auto-escape
$node->modifiers = '|checkurl|escape'; // auto-escape

$writer = Latte\PhpWriter::using($node);

Expand Down
24 changes: 12 additions & 12 deletions tests/BustCache/BustCacheMacroTest.phpt
Expand Up @@ -26,29 +26,29 @@ class BustCacheMacroTest extends TestCase

$node = $compiler->expandMacro('bustCache', '"/test.txt"');
Assert::true($node->empty);
Assert::match(
'<?php echo %a%escape%a%\'/test.txt?a1d0c6e83f\') ?>',
Assert::same(
'<?php echo LR\Filters::escapeHtmlText(\'/test.txt?a1d0c6e83f\') ?>',
$node->openingCode
);

$node = $compiler->expandMacro('bustCache', "'/test.txt'");
Assert::true($node->empty);
Assert::match(
'<?php echo %a%escape%a%\'/test.txt?a1d0c6e83f\') ?>',
Assert::same(
'<?php echo LR\Filters::escapeHtmlText(\'/test.txt?a1d0c6e83f\') ?>',
$node->openingCode
);

$node = $compiler->expandMacro('bustCache', '/test.txt');
Assert::true($node->empty);
Assert::match(
'<?php echo %a%escape%a%\'/test.txt?a1d0c6e83f\') ?>',
Assert::same(
'<?php echo LR\Filters::escapeHtmlText(\'/test.txt?a1d0c6e83f\') ?>',
$node->openingCode
);

$node = $compiler->expandMacro('bustCache', '$file');
Assert::true($node->empty);
Assert::match(
'#<\?php echo .*escape.*safeUrl.*\$file \. \'\?\' \. Nepada\\\\BustCache\\\\Helpers::hash\(\'' . preg_quote(self::FIXTURES_DIR, '#') . '\' . \$file\)\)\) \?>#i',
Assert::same(
'<?php echo LR\Filters::escapeHtmlText(LR\Filters::safeUrl($file . \'?\' . Nepada\BustCache\Helpers::hash(\'' . self::FIXTURES_DIR . '\' . $file))) ?>',
$node->openingCode
);
}
Expand All @@ -60,15 +60,15 @@ class BustCacheMacroTest extends TestCase

$node = $compiler->expandMacro('bustCache', '/test.txt');
Assert::true($node->empty);
Assert::match(
'#<\?php echo .*escape.*safeUrl.*"/test\.txt" \. \'\?\' \. Nepada\\\\BustCache\\\\Helpers::timestamp\(\'' . preg_quote(self::FIXTURES_DIR, '#') . '\' . "/test\.txt"\)\)\) \?>#i',
Assert::same(
'<?php echo LR\Filters::escapeHtmlText(LR\Filters::safeUrl("/test.txt" . \'?\' . Nepada\BustCache\Helpers::timestamp(\'' . self::FIXTURES_DIR . '\' . "/test.txt"))) ?>',
$node->openingCode
);

$node = $compiler->expandMacro('bustCache', '$file');
Assert::true($node->empty);
Assert::match(
'#<\?php echo .*escape.*safeUrl.*\$file \. \'\?\' \. Nepada\\\\BustCache\\\\Helpers::timestamp\(\'' . preg_quote(self::FIXTURES_DIR, '#') . '\' . \$file\)\)\) \?>#i',
Assert::same(
'<?php echo LR\Filters::escapeHtmlText(LR\Filters::safeUrl($file . \'?\' . Nepada\BustCache\Helpers::timestamp(\'' . self::FIXTURES_DIR . '\' . $file))) ?>',
$node->openingCode
);
}
Expand Down

0 comments on commit 82195dd

Please sign in to comment.