From 126a49185229f248eae8c485b3e16e029ebcb353 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 23 Oct 2026 23:29:59 +0200 Subject: =?UTF-8?q?audit=20claude=20code=201,=20validation=20formulaire=20?= =?UTF-8?q?toujours=20ok,=20=C3=A9chappement=20dans=20URL,=20quelques=20ht?= =?UTF-8?q?mlspecialchars=20manquants,=20fonction=20Security::validateURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Service/Security.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Service/Security.php') 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 return trim(htmLawed($chaine, self::$configHtmLawed, self::$specHtmLawed)); } + public static function validateURL(string $link): bool + { + return filter_var($link, FILTER_VALIDATE_URL) !== false // c'est une URL? + && in_array(strtolower(parse_url($link, PHP_URL_SCHEME) ?? ''), ['http', 'https'], true); // PHP_URL_SCHEME pour récupérer le protocole + } + public static function secureFileName(string $chaine): string { // sécuriser un nom avec chemin avec basename? @@ -83,7 +89,7 @@ class Security } // lien sans http:// -function fixLinks($data) +function fixLinks(string $data): string { // 1/ // 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:// -- cgit v1.2.3