| 1 |
lars |
1 |
<?php
|
|
|
2 |
// $Id: pager_test_xss.php,v 1.1 2005/07/04 08:08:46 quipo Exp $
|
|
|
3 |
|
|
|
4 |
//override url
|
|
|
5 |
$_SERVER['PHP_SELF'] = '">test';
|
|
|
6 |
|
|
|
7 |
require_once 'simple_include.php';
|
|
|
8 |
require_once 'pager_include.php';
|
|
|
9 |
|
|
|
10 |
class TestOfPagerXSS extends UnitTestCase {
|
|
|
11 |
var $pager;
|
|
|
12 |
var $baseurl;
|
|
|
13 |
function TestOfPagerXSS($name='Test of Pager - XSS attacks') {
|
|
|
14 |
$this->UnitTestCase($name);
|
|
|
15 |
}
|
|
|
16 |
function setUp() {
|
|
|
17 |
$options = array(
|
|
|
18 |
'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
|
|
|
19 |
'perPage' => 5,
|
|
|
20 |
);
|
|
|
21 |
$this->pager = Pager::factory($options);
|
|
|
22 |
$this->baseurl = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
|
|
|
23 |
}
|
|
|
24 |
function tearDown() {
|
|
|
25 |
unset($this->pager);
|
|
|
26 |
}
|
|
|
27 |
function testXSS() {
|
|
|
28 |
$options = array(
|
|
|
29 |
'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
|
|
|
30 |
'perPage' => 5,
|
|
|
31 |
'nextImg' => '»'
|
|
|
32 |
);
|
|
|
33 |
$this->pager = Pager::factory($options);
|
|
|
34 |
$expected = ' <a href="./">test?pageID=2" title="next page">»</a> ';
|
|
|
35 |
$this->assertEqual($expected, $this->pager->_getNextLink());
|
|
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
if (!defined('TEST_RUNNING')) {
|
|
|
39 |
define('TEST_RUNNING', true);
|
|
|
40 |
$test = &new TestOfPagerXSS();
|
|
|
41 |
$test->run(new HtmlReporter());
|
|
|
42 |
}
|
|
|
43 |
?>
|