1<?php
2
3class toolbar_test extends DokuWikiTest {
4
5    function test_encode_toolbar_signature() {
6        global $conf, $INFO, $INPUT;
7
8        $conf['signature'] = '" --- \\\\n //[[@MAIL@|@NAME@]] (@USER@) @DATE@//"';
9        $_SERVER['REMOTE_USER'] = 'john';
10        $INFO['userinfo']['name'] = '/*!]]>*/</script><script>alert("\123\")</script>';
11        $INFO['userinfo']['mail'] = 'example@example.org';
12
13        $date = str_replace('/', '\/', dformat());
14
15        $expected = '"\" --- \\\n \/\/[[example@example.org|\/*!]]>*\/<\/script><script>'.
16                    'alert(\"\\\\123\\\\\\")<\/script>]] (john) '.$date.'\/\/\""';
17
18        $this->assertEquals($expected, toolbar_signature());
19    }
20}
21