Fix error when url title contains quotes
This commit is contained in:
parent
f6eda3c727
commit
ae4d05d186
4 changed files with 12 additions and 4 deletions
|
@ -80,11 +80,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
$info = $cache->get(true);
|
$info = $cache->get(true);
|
||||||
|
|
||||||
if (empty($wish_title) && empty($wish->title)) {
|
if (empty($wish_title) && empty($wish->title)) {
|
||||||
$wish_title = $info->title;
|
$wish_title = Sanitiser::getTitle($info->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($wish_description) && empty($wish->description)) {
|
if (empty($wish_description) && empty($wish->description)) {
|
||||||
$wish_description = $info->description;
|
$wish_description = Sanitiser::getText($info->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Image */
|
/** Image */
|
||||||
|
@ -152,11 +152,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
$info = $cache->get(true);
|
$info = $cache->get(true);
|
||||||
|
|
||||||
if (empty($wish_title) && isset($info->title)) {
|
if (empty($wish_title) && isset($info->title)) {
|
||||||
$wish_title = $info->title;
|
$wish_title = Sanitiser::getTitle($info->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($wish_description) && isset($info->description)) {
|
if (empty($wish_description) && isset($info->description)) {
|
||||||
$wish_description = $info->description;
|
$wish_description = Sanitiser::getText($info->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Image */
|
/** Image */
|
||||||
|
|
|
@ -4,6 +4,10 @@ namespace wishthis;
|
||||||
|
|
||||||
class Sanitiser
|
class Sanitiser
|
||||||
{
|
{
|
||||||
|
public static function render(string $text): string {
|
||||||
|
return html_entity_decode($text);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getNumber(mixed $valueToSanitise): float
|
public static function getNumber(mixed $valueToSanitise): float
|
||||||
{
|
{
|
||||||
return floatval(preg_replace('/[^0-9\.]+/', '', $valueToSanitise));
|
return floatval(preg_replace('/[^0-9\.]+/', '', $valueToSanitise));
|
||||||
|
|
|
@ -108,6 +108,9 @@ class Wish
|
||||||
$this->$key = $this->info->$key;
|
$this->$key = $this->info->$key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->title = Sanitiser::render($this->title);
|
||||||
|
$this->description = Sanitiser::render($this->description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ $page->navigation();
|
||||||
<li><?= __('Wish image not showing') ?></li>
|
<li><?= __('Wish image not showing') ?></li>
|
||||||
<li><?= __('An error when saving a wish with a really long URL') ?></li>
|
<li><?= __('An error when saving a wish with a really long URL') ?></li>
|
||||||
<li><?= __('Redirect errors on Nginx') ?></li>
|
<li><?= __('Redirect errors on Nginx') ?></li>
|
||||||
|
<li><?= __('An error when fetching title from an URL containing quotes') ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue