Skip to content

Commit

Permalink
Merge pull request #13500 from craftcms/bugfix/13495-purify-twig-filt…
Browse files Browse the repository at this point in the history
…er-adjustment

make “purify”  twig filter more forgiving
  • Loading branch information
brandonkelly authored Aug 3, 2023
2 parents 603fc9e + 4aa4fd5 commit 89995f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fixed a bug where `craft\helpers\DateTimeHelper::toDateInterval()` didn’t support negative integers. ([#13463](https://github.com/craftcms/cms/pull/13463))
- Fixed a bug where admin tables were initially displaying an empty results message rather than a loading spinner, when the initial data was loading via Ajax. ([#13459](https://github.com/craftcms/cms/issues/13459))
- Fixed a bug where garbage collection could terminate prematurely if an exception was thrown when deleting a pending user. ([#13490](https://github.com/craftcms/cms/issues/13490))
- Fixed an error that occurred if the `purify` Twig filter was applied to a `null` value. ([#13495](https://github.com/craftcms/cms/issues/13495))
- Fixed an information disclosure vulnerability.

## 4.4.16.1 - 2023-07-19
Expand Down
10 changes: 7 additions & 3 deletions src/web/twig/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,14 +801,18 @@ public function prependFilter(string $tag, string $html, ?string $ifExists = nul
/**
* Purifies the given HTML using HTML Purifier.
*
* @param string $html The HTML to be purified
* @param string|null $html The HTML to be purified
* @param string|array|null $config The HTML Purifier config. This can either be the name of a JSON file within
* `config/htmlpurifier/` (sans `.json` extension) or a config array.
* @return string The purified HTML
* @return string|null The purified HTML
* @since 3.4.0
*/
public function purifyFilter(string $html, array|string|null $config = null): string
public function purifyFilter(?string $html, array|string|null $config = null): ?string
{
if ($html === null) {
return null;
}

if (is_string($config)) {
$path = Craft::$app->getPath()->getConfigPath() . DIRECTORY_SEPARATOR . 'htmlpurifier' .
DIRECTORY_SEPARATOR . $config . '.json';
Expand Down

0 comments on commit 89995f4

Please sign in to comment.