Просмотр исходного кода

Avoid falsy guid (#5412)

Whitespace strings, empty strings, 0 are all problematic when working with GUIDs. so avoid them.
Alexandre Alapetite 2 лет назад
Родитель
Сommit
d554d0f673
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      app/Models/Entry.php

+ 4 - 3
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 {