~ubuntu-branches/ubuntu/hardy/phpmyadmin/hardy-updates

« back to all changes in this revision

Viewing changes to test/PMA_escapeJsString_test.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2007-10-17 22:54:41 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20071017225441-xqwg7f10chaprdoe
Tags: 4:2.11.1.2-1

* New upstream release.
* Addresses two cross site scripting issues:
  PMASA-2007-5, PMASA-2007-6
  (CVE-2007-5386, closes: #446451)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/* vim: expandtab sw=4 ts=4 sts=4: */
 
3
/**
 
4
 * Test for javascript escaping.
 
5
 *
 
6
 * @author Michal Čihař <michal@cihar.com>
 
7
 * @package phpMyAdmin-test
 
8
 * @version $Id: PMA_escapeJsString_test.php 10237 2007-04-01 08:23:23Z cybot_tm $
 
9
 */
 
10
 
 
11
/**
 
12
 * Tests core.
 
13
 */
 
14
require_once 'PHPUnit/Framework.php';
 
15
 
 
16
/**
 
17
 * Include to test.
 
18
 */
 
19
require_once './libraries/js_escape.lib.php';
 
20
 
 
21
/**
 
22
 * Test java script escaping.
 
23
 *
 
24
 */
 
25
class PMA_escapeJsString_test extends PHPUnit_Framework_TestCase
 
26
{
 
27
    public function testEscape_1()
 
28
    {
 
29
        $this->assertEquals('\\\';', PMA_escapeJsString('\';'));
 
30
    }
 
31
 
 
32
    public function testEscape_2()
 
33
    {
 
34
        $this->assertEquals('\r\n\\\'<scrIpt></\' + \'script>', PMA_escapeJsString("\r\n'<scrIpt></sCRIPT>"));
 
35
    }
 
36
 
 
37
    public function testEscape_3()
 
38
    {
 
39
        $this->assertEquals('\\\';[XSS]', PMA_escapeJsString('\';[XSS]'));
 
40
    }
 
41
 
 
42
    public function testEscape_4()
 
43
    {
 
44
        $this->assertEquals('</\' + \'script></head><body>[HTML]', PMA_escapeJsString('</SCRIPT></head><body>[HTML]'));
 
45
    }
 
46
 
 
47
    public function testEscape_5()
 
48
    {
 
49
        $this->assertEquals('"\\\'\\\\\\\'"', PMA_escapeJsString('"\'\\\'"'));
 
50
    }
 
51
 
 
52
    public function testEscape_6()
 
53
    {
 
54
        $this->assertEquals("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", PMA_escapeJsString("\\''''''''''''\\"));
 
55
    }
 
56
 
 
57
}
 
58
?>