~hexmode/+junk/main

« back to all changes in this revision

Viewing changes to install-files/apps/phpmyadmin2.10.1/test/escape_js_string.php

  • Committer: Mark A. Hershberger
  • Date: 2008-01-05 19:38:56 UTC
  • Revision ID: hershberger@spawn-xp-20080105193856-6rnzgwa4nehue3qj
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/* $Id: escape_js_string.php 9913 2007-02-03 17:30:07Z lem9 $ */
 
3
// vim: expandtab sw=4 ts=4 sts=4:
 
4
 
 
5
/**
 
6
 * Test for javascript escaping.
 
7
 *
 
8
 * @author Michal Čihař <michal@cihar.com>
 
9
 * @package phpMyAdmin-test
 
10
 */
 
11
 
 
12
/**
 
13
 * Tests core.
 
14
 */
 
15
include('./core.lib.php');
 
16
/**
 
17
 * Include to test.
 
18
 */
 
19
include('./libraries/js_escape.lib.php');
 
20
 
 
21
/**
 
22
 * Test java script escaping.
 
23
 *
 
24
 * @uses    PMA_escapeJsString()
 
25
 * @uses    PMA_test_string()
 
26
 * @param string string to escape
 
27
 * @param string expected result
 
28
 */
 
29
function PMA_test_escape($test, $expected) {
 
30
    PMA_test_string('PMA_escapeJsString', $test, PMA_escapeJsString($test), $expected);
 
31
}
 
32
 
 
33
PMA_test_escape('\';', '\\\';');
 
34
PMA_test_escape("\r\n'<scrIpt></sCRIPT>", '\r\n\\\'<scrIpt></\' + \'script>');
 
35
PMA_test_escape('\';[XSS]', '\\\';[XSS]');
 
36
PMA_test_escape('</SCRIPT></head><body>[HTML]', '</\' + \'script></head><body>[HTML]');
 
37
PMA_test_escape('"\'\\\'"', '"\\\'\\\\\\\'"');
 
38
PMA_test_escape("\\''''''''''''\\", "\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\");
 
39
?>