aboutsummaryrefslogtreecommitdiff
path: root/src/Service/Security.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Service/Security.php')
-rw-r--r--src/Service/Security.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Service/Security.php b/src/Service/Security.php
index 0fbd8b7..bb04535 100644
--- a/src/Service/Security.php
+++ b/src/Service/Security.php
@@ -27,6 +27,12 @@ class Security
27 return trim(htmLawed($chaine, self::$configHtmLawed, self::$specHtmLawed)); 27 return trim(htmLawed($chaine, self::$configHtmLawed, self::$specHtmLawed));
28 } 28 }
29 29
30 public static function validateURL(string $link): bool
31 {
32 return filter_var($link, FILTER_VALIDATE_URL) !== false // c'est une URL?
33 && in_array(strtolower(parse_url($link, PHP_URL_SCHEME) ?? ''), ['http', 'https'], true); // PHP_URL_SCHEME pour récupérer le protocole
34 }
35
30 public static function secureFileName(string $chaine): string 36 public static function secureFileName(string $chaine): string
31 { 37 {
32 // sécuriser un nom avec chemin avec basename? 38 // sécuriser un nom avec chemin avec basename?
@@ -83,7 +89,7 @@ class Security
83} 89}
84 90
85// lien sans http:// 91// lien sans http://
86function fixLinks($data) 92function fixLinks(string $data): string
87{ 93{
88 // 1/ 94 // 1/
89 // si une adresse est de type "domaine.fr" sans le http:// devant, le comportement des navigateurs est de rechercher un fichier comme si mon adresse commençait par file:// 95 // si une adresse est de type "domaine.fr" sans le http:// devant, le comportement des navigateurs est de rechercher un fichier comme si mon adresse commençait par file://