Explorar el Código

Avoid falsy guid (#5412)

Whitespace strings, empty strings, 0 are all problematic when working with GUIDs. so avoid them.
Alexandre Alapetite hace 2 años
padre
commit
d554d0f673
Se han modificado 1 ficheros con 4 adiciones y 3 borrados
  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 {