File: pager_test_xss.php

package info (click to toggle)
php-pager 2.4.6-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 304 kB
  • ctags: 763
  • sloc: php: 2,620; xml: 660; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
// $Id: pager_test_xss.php,v 1.1 2005/07/04 08:08:46 quipo Exp $

//override url
$_SERVER['PHP_SELF'] = '">test';

require_once 'simple_include.php';
require_once 'pager_include.php';

class TestOfPagerXSS extends UnitTestCase {
    var $pager;
    var $baseurl;
    function TestOfPagerXSS($name='Test of Pager - XSS attacks') {
        $this->UnitTestCase($name);
    }
    function setUp() {
        $options = array(
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
            'perPage'  => 5,
        );
        $this->pager = Pager::factory($options);
        $this->baseurl = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
    }
    function tearDown() {
        unset($this->pager);
    }
    function testXSS() {
        $options = array(
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
            'perPage'  => 5,
            'nextImg'  => '&raquo;'
        );
        $this->pager = Pager::factory($options);
        $expected = '&nbsp;<a href="./&quot;&gt;test?pageID=2" title="next page">&raquo;</a>&nbsp;';
        $this->assertEqual($expected, $this->pager->_getNextLink());
    }
}
if (!defined('TEST_RUNNING')) {
    define('TEST_RUNNING', true);
    $test = &new TestOfPagerXSS();
    $test->run(new HtmlReporter());
}
?>