create-prisma-php-app 1.17.5 → 1.17.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/Lib/Validator.php +9 -10
- package/package.json +1 -1
|
@@ -12,20 +12,19 @@ class Validator
|
|
|
12
12
|
/**
|
|
13
13
|
* Validate and sanitize a string.
|
|
14
14
|
*
|
|
15
|
-
* This function
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* This function converts the input to a string, trims any leading or trailing
|
|
16
|
+
* whitespace, and converts special characters to HTML entities to prevent
|
|
17
|
+
* XSS attacks. If the input is null, an empty string is returned.
|
|
18
18
|
*
|
|
19
|
-
* @param mixed $value The value to validate and sanitize.
|
|
20
|
-
* @return string The sanitized string or
|
|
19
|
+
* @param mixed $value The value to validate and sanitize. This can be of any type.
|
|
20
|
+
* @return string The sanitized string. If the input is not a string or null, it is converted to its string representation before sanitization. If the input is null, an empty string is returned.
|
|
21
21
|
*/
|
|
22
22
|
public static function string($value): string
|
|
23
23
|
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return '';
|
|
24
|
+
// Convert the value to a string if it's not null
|
|
25
|
+
$stringValue = $value !== null ? (string)$value : '';
|
|
26
|
+
// Return the HTML-escaped string
|
|
27
|
+
return htmlspecialchars(trim($stringValue), ENT_QUOTES, 'UTF-8');
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
/**
|