Fix error when url title contains quotes

This commit is contained in:
grandeljay 2022-08-08 09:59:10 +02:00
parent f6eda3c727
commit ae4d05d186
4 changed files with 12 additions and 4 deletions

View file

@ -80,11 +80,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
$info = $cache->get(true);
if (empty($wish_title) && empty($wish->title)) {
$wish_title = $info->title;
$wish_title = Sanitiser::getTitle($info->title);
}
if (empty($wish_description) && empty($wish->description)) {
$wish_description = $info->description;
$wish_description = Sanitiser::getText($info->description);
}
/** Image */
@ -152,11 +152,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
$info = $cache->get(true);
if (empty($wish_title) && isset($info->title)) {
$wish_title = $info->title;
$wish_title = Sanitiser::getTitle($info->title);
}
if (empty($wish_description) && isset($info->description)) {
$wish_description = $info->description;
$wish_description = Sanitiser::getText($info->description);
}
/** Image */

View file

@ -4,6 +4,10 @@ namespace wishthis;
class Sanitiser
{
public static function render(string $text): string {
return html_entity_decode($text);
}
public static function getNumber(mixed $valueToSanitise): float
{
return floatval(preg_replace('/[^0-9\.]+/', '', $valueToSanitise));

View file

@ -108,6 +108,9 @@ class Wish
$this->$key = $this->info->$key;
}
}
$this->title = Sanitiser::render($this->title);
$this->description = Sanitiser::render($this->description);
}
}

View file

@ -67,6 +67,7 @@ $page->navigation();
<li><?= __('Wish image not showing') ?></li>
<li><?= __('An error when saving a wish with a really long URL') ?></li>
<li><?= __('Redirect errors on Nginx') ?></li>
<li><?= __('An error when fetching title from an URL containing quotes') ?></li>
</ul>
</div>