Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_escapeJsString_test.php « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b54cea65dcf0492f3c58c81f1660148f22a2118 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Test for javascript escaping.
 *
 * @package phpMyAdmin-test
 * @version $Id$
 */

/**
 * Tests core.
 */
require_once 'PHPUnit/Framework.php';

/**
 * Include to test.
 */
require_once './libraries/js_escape.lib.php';

/**
 * Test java script escaping.
 *
 * @package phpMyAdmin-test
 */
class PMA_escapeJsString_test extends PHPUnit_Framework_TestCase
{
    public function testEscape_1()
    {
        $this->assertEquals('\\\';', PMA_escapeJsString('\';'));
    }

    public function testEscape_2()
    {
        $this->assertEquals('\r\n\\\'<scrIpt></\' + \'script>', PMA_escapeJsString("\r\n'<scrIpt></sCRIPT>"));
    }

    public function testEscape_3()
    {
        $this->assertEquals('\\\';[XSS]', PMA_escapeJsString('\';[XSS]'));
    }

    public function testEscape_4()
    {
        $this->assertEquals('</\' + \'script></head><body>[HTML]', PMA_escapeJsString('</SCRIPT></head><body>[HTML]'));
    }

    public function testEscape_5()
    {
        $this->assertEquals('"\\\'\\\\\\\'"', PMA_escapeJsString('"\'\\\'"'));
    }

    public function testEscape_6()
    {
        $this->assertEquals("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", PMA_escapeJsString("\\''''''''''''\\"));
    }

}
?>