Skip to content

Commit 1ff07b7

Browse files
committed
Test URLs with XSS
1 parent 9ebbce5 commit 1ff07b7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/PagerTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,37 @@ public function testPageUrl() : void
130130
self::assertSame('http://localhost/?page=15', $this->pager->getPageUrl(15));
131131
}
132132

133+
/**
134+
* @runInSeparateProcess
135+
*/
136+
public function testPageUrlWithXss() : void
137+
{
138+
$_SERVER['HTTP_HOST'] = 'localhost';
139+
$_SERVER['REQUEST_URI'] = '/?foo=<script>alert("xss")</script>';
140+
$this->pager = new Pager(0, 10, 31);
141+
self::assertSame(
142+
'http://localhost/?foo=%3Cscript%3Ealert%28%22xss%22%29%3C%2Fscript%3E&page=1',
143+
$this->pager->getCurrentPageUrl()
144+
);
145+
self::assertNull($this->pager->getPreviousPageUrl());
146+
self::assertSame(
147+
'http://localhost/?foo=%3Cscript%3Ealert%28%22xss%22%29%3C%2Fscript%3E&page=1',
148+
$this->pager->getFirstPageUrl()
149+
);
150+
self::assertSame(
151+
'http://localhost/?foo=%3Cscript%3Ealert%28%22xss%22%29%3C%2Fscript%3E&page=2',
152+
$this->pager->getNextPageUrl()
153+
);
154+
self::assertSame(
155+
'http://localhost/?foo=%3Cscript%3Ealert%28%22xss%22%29%3C%2Fscript%3E&page=4',
156+
$this->pager->getLastPageUrl()
157+
);
158+
self::assertSame(
159+
'http://localhost/?foo=%3Cscript%3Ealert%28%22xss%22%29%3C%2Fscript%3E&page=15',
160+
$this->pager->getPageUrl(15)
161+
);
162+
}
163+
133164
/**
134165
* @runInSeparateProcess
135166
*/

0 commit comments

Comments
 (0)