Skip to content

Commit

Permalink
fixed undefined method exception in request cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Sep 7, 2023
1 parent 290a645 commit fea9c33
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to this project will be documented in this file.

## [2.229.2] - 2023-09-07
- Fixed: undefined method exception in RequestCleaner

## [2.229.1] - 2023-09-06
- Fixed: PHP8 warning fix for `getImageData()` in `Twig\ImageExtension.php`
- Changed: method collection/reflection, cosmetic improvements in `Classes\ClassUtil.php`
Expand Down
27 changes: 26 additions & 1 deletion src/Request/RequestCleaner.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

/*
* Copyright (c) 2023 Heimrich & Hannot GmbH
*
* @license LGPL-3.0-or-later
*/

namespace HeimrichHannot\UtilsBundle\Request;

use Contao\Input;
Expand Down Expand Up @@ -256,4 +262,23 @@ public function tidy($varValue, string $allowedTags = '', bool $decodeEntities =

return $varValue;
}
}

/**
* Restore basic entities.
*
* @param string $buffer The string with the tags to be replaced
* @param bool $decodeEntities If true, all entities will be decoded
*
* @return string The string with the original entities
*/
public function restoreBasicEntities(string $buffer, bool $decodeEntities = false): string
{
$buffer = str_replace(['[&]', '[&amp;]', '[lt]', '[gt]', '[nbsp]', '[-]'], ['&amp;', '&amp;', '&lt;', '&gt;', '&nbsp;', '&shy;'], $buffer);

if ($decodeEntities) {
$buffer = StringUtil::decodeEntities($buffer);
}

return $buffer;
}
}

0 comments on commit fea9c33

Please sign in to comment.