From d554d0f6736c5cf94cb2a8fa61f3b6187b86ffa2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 22 May 2023 10:01:43 +0200 Subject: Avoid falsy guid (#5412) Whitespace strings, empty strings, 0 are all problematic when working with GUIDs. so avoid them. --- app/Models/Entry.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 70b2fa5f0..9e3e97d1a 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -432,9 +432,10 @@ HTML; } } public function _guid(string $value): void { - if ($value == '') { + $value = trim($value); + if (empty($value)) { $value = $this->link; - if ($value == '') { + if (empty($value)) { $value = $this->hash(); } } @@ -468,7 +469,7 @@ HTML; } public function _link(string $value): void { $this->hash = ''; - $this->link = $value; + $this->link = trim($value); } /** @param int|string $value */ public function _date($value): void { -- cgit v1.2.3