diff --git a/.gitignore b/.gitignore
index b0c31dd..24de360 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
composer.lock
package-lock.json
/lib/
+tests/.phpunit.result.cache
\ No newline at end of file
diff --git a/Modules/Sfw.php b/Modules/Sfw.php
index d5da741..1205141 100644
--- a/Modules/Sfw.php
+++ b/Modules/Sfw.php
@@ -286,6 +286,8 @@ public function diePage($result)
$request_uri = preg_replace('%sfw_test_ip=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}&?%', '', $request_uri);
}
+ $request_uri = htmlspecialchars($request_uri, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+
// @ToDo not implemented yet
// Custom Logo
//$custom_logo_img = '';
diff --git a/composer.json b/composer.json
index 0aa27ca..d8b6669 100644
--- a/composer.json
+++ b/composer.json
@@ -24,7 +24,7 @@
},
"require-dev": {
"vimeo/psalm": "^4.8",
- "phpunit/phpunit": "^7.5",
+ "phpunit/phpunit": "^8.5.52",
"squizlabs/php_codesniffer": "3.*",
"phpcompatibility/php-compatibility": "^9.3"
},
@@ -41,5 +41,10 @@
"psr-4": {
"Cleantalk\\Common\\Firewall\\": "/"
}
+ },
+ "config": {
+ "allow-plugins": {
+ "cleantalk/apbct-installer": true
+ }
}
}
diff --git a/tests/Modules/SFW/SfwXssProtectionTest.php b/tests/Modules/SFW/SfwXssProtectionTest.php
new file mode 100644
index 0000000..4393891
--- /dev/null
+++ b/tests/Modules/SFW/SfwXssProtectionTest.php
@@ -0,0 +1,174 @@
+assertSame($expectedOutput, $sanitized);
+
+ // Additional check: the result should not contain unescaped tags
+ $this->assertStringNotContainsString('',
+ '/<script>alert("XSS")</script>'
+ ],
+ 'script with single quotes' => [
+ "/",
+ '/<script>alert('XSS')</script>'
+ ],
+ 'img onerror' => [
+ '/
',
+ '/<img src=x onerror=alert(1)>'
+ ],
+ 'svg onload' => [
+ '/