aboutsummaryrefslogtreecommitdiff
path: root/src/Service/URL.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-23 23:29:59 +0200
committerpolo <ordipolo@gmx.fr>2026-10-23 23:29:59 +0200
commit126a49185229f248eae8c485b3e16e029ebcb353 (patch)
tree7877918b7067103d667d522883e04f0129a1addc /src/Service/URL.php
parent5a25142d778eafdec33d10d673bd4abc5fe38d1c (diff)
downloadcms-126a49185229f248eae8c485b3e16e029ebcb353.tar.gz
cms-126a49185229f248eae8c485b3e16e029ebcb353.tar.bz2
cms-126a49185229f248eae8c485b3e16e029ebcb353.zip
audit claude code 1, validation formulaire toujours ok, échappement dans URL, quelques htmlspecialchars manquants, fonction Security::validateURLpolo1
Diffstat (limited to 'src/Service/URL.php')
-rw-r--r--src/Service/URL.php27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/Service/URL.php b/src/Service/URL.php
index 035f572..e6f986c 100644
--- a/src/Service/URL.php
+++ b/src/Service/URL.php
@@ -58,33 +58,20 @@ class URL implements \Stringable
58 public function setAnchor(string $anchor = ''): void 58 public function setAnchor(string $anchor = ''): void
59 { 59 {
60 if($anchor != ''){ 60 if($anchor != ''){
61 $this->anchor = '#' . ltrim($anchor, '#'); 61 $this->anchor = '#' . rawurlencode(ltrim($anchor, '#'));// rawurlencode échappe les mêmes caractères
62 } 62 }
63 else{ 63 else{
64 $this->anchor = ''; 64 $this->anchor = '';
65 } 65 }
66 } 66 }
67 67
68 private function makeParams(): string
69 {
70 $output = '';
71 $first = true;
72
73 foreach($this->params as $key => $value) {
74 if($first){
75 $output .= '?';
76 $first = false;
77 }
78 else{
79 $output .= '&';
80 }
81 $output .= $key . '=' . $value;
82 }
83 return $output;
84 }
85
86 public function __toString(): string 68 public function __toString(): string
87 { 69 {
88 return self::$protocol . self::$host . self::$port . self::$path . $this->makeParams() . $this->anchor; 70 return self::$protocol . self::$host . self::$port . self::$path
71 . ($this->params ? '?' . http_build_query($this->params) : '')
72 . $this->anchor;
73 // http_build_query change un tableau comme ['key1' => 'value 1', 'key2' => 'value 2']
74 // en chaine: key1=value+1&key2=value+2
75 // les caractères ", ', <, >, &, #, = et espaces sont échappés (comme avec rawurlencode pour les ancres)
89 } 76 }
90} \ No newline at end of file 77} \ No newline at end of file