diff --git a/src/Wrappers/Traits/EventTrait.php b/src/Wrappers/Traits/EventTrait.php index a370c7b..d236387 100644 --- a/src/Wrappers/Traits/EventTrait.php +++ b/src/Wrappers/Traits/EventTrait.php @@ -278,7 +278,7 @@ final public function setRequest() { ], 'headers' => [ 'content_type' => $headers['Content-Type'] ?? '', - 'user_agent' => $headers['User-Agent'] ?? '', + 'user_agent' => $this->clean_non_chars($headers['User-Agent']) ?? '', 'cookie' => $this->getCookieHeader($headers['Cookie'] ?? ''), ], 'env' => $this->getEnv(), @@ -357,6 +357,10 @@ final protected function getCookieHeader(string $cookieHeader) : string // Returns an empty string if cookies are masked. return empty($cookieMask) ? $cookieHeader : ''; } + + final protected function clean_non_chars($string) { + return preg_replace('/[^A-Za-z0-9\-\;\(\)\,\ \/\.]/', '', $string); // Removes special chars. + } }