Skip to content

Commit 9d0e169

Browse files
authored
Merge pull request #1856
* fix: Encode XSS related characters and strip tags.
1 parent c39b60c commit 9d0e169

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/SP/Html/Html.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ public static function getSafeUrl(string $url): string
191191
}
192192

193193
return preg_replace_callback(
194-
'/[^:\/@?&=#%\w]+/u',
194+
'/["<>\']+/u',
195195
function ($matches)
196196
{
197197
return urlencode($matches[0]);
198198
},
199-
$url
199+
strip_tags($url)
200200
);
201201
}
202202
}

lib/SP/Services/Install/Installer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ final class Installer extends Service
6060
/**
6161
* sysPass' version and build number
6262
*/
63-
const VERSION = [3, 2, 10];
63+
const VERSION = [3, 2, 11];
6464
const VERSION_TEXT = '3.2';
65-
const BUILD = 22070101;
65+
const BUILD = 22070201;
6666

6767
/**
6868
* @var DatabaseSetupInterface

tests/SP/Html/HtmlTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testGetSafeUrlOk()
5656
*/
5757
public function testGetSafeUrlEncoded(string $url)
5858
{
59-
$this->assertEquals(0, preg_match('/["<>]+/', Html::getSafeUrl($url)));
59+
$this->assertEquals(0, preg_match('/["<>\']+/', Html::getSafeUrl($url)));
6060
}
6161

6262
private function urlProvider(): array
@@ -67,6 +67,7 @@ private function urlProvider(): array
6767
['https://foo.com/"><script>alert("TEST");</script>'],
6868
['https://foo.com/"%20onClick="alert(\'TEST\'")'],
6969
['https://foo.com/" onClick="alert(\'TEST\')"'],
70+
['mongodb+srv://cluster.foo.mongodb.net/bar'],
7071
];
7172
}
7273
}

0 commit comments

Comments
 (0)