Commit | Line | Data |
---|---|---|
09ca2cbf JR |
1 | /* |
2 | The software in this package is distributed under the GNU General | |
3 | Public License version 2 (with a special exception described below). | |
4 | ||
5 | A copy of GNU General Public License (GPL) is included in this distribution, | |
6 | in the file COPYING.GPL. | |
7 | ||
8 | As a special exception, if other files instantiate templates or use macros | |
9 | or inline functions from this file, or you compile this file and link it | |
10 | with other works to produce a work based on this file, this file | |
11 | does not by itself cause the resulting work to be covered | |
12 | by the GNU General Public License. | |
13 | ||
14 | However the source code for this file must still be made available | |
15 | in accordance with section (3) of the GNU General Public License. | |
16 | ||
17 | This exception does not invalidate any other reasons why a work based | |
18 | on this file might be covered by the GNU General Public License. | |
19 | */ | |
20 | /** @file | |
21 | * @brief unit test for the restricted html functions. | |
22 | * | |
23 | * @copyright © Copyright 2017 Intra2net AG | |
24 | * | |
25 | */ | |
26 | #define BOOST_TEST_DYN_LINK | |
27 | #include <boost/test/unit_test.hpp> | |
28 | ||
29 | #include <restricted_html.hpp> | |
30 | ||
31 | using namespace std; | |
32 | using namespace I2n; | |
33 | ||
34 | BOOST_AUTO_TEST_SUITE(test_restricted_html) | |
35 | ||
36 | ||
a93685ca JR |
37 | BOOST_AUTO_TEST_CASE(DecodeStringURL) |
38 | { | |
39 | string output = decode_url("%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D"); | |
40 | BOOST_CHECK_EQUAL(string("www.google.com"), output); | |
41 | } | |
42 | ||
43 | BOOST_AUTO_TEST_CASE(DecodeStringURL2) | |
44 | { | |
45 | string output = decode_url("%3Cscript%3Ealert%28document.cookie%29%3C%2Fscr" | |
46 | "ipt%3E"); | |
47 | BOOST_CHECK_EQUAL(string("<script>alert(document.cookie)</script>"), output); | |
48 | } | |
49 | ||
50 | BOOST_AUTO_TEST_CASE(EncodeStringURL) | |
51 | { | |
52 | string output = encode_url("http://www.domain.com/params?param=b'ar:!~/"); | |
53 | BOOST_CHECK_EQUAL(string("http%3A%2F%2Fwww%2Edomain%2Ecom%2Fparams%3Fparam%" | |
54 | "3Db%27ar%3A%21%7E%2F"), output); | |
55 | } | |
56 | ||
57 | BOOST_AUTO_TEST_CASE(EncodeStringURL2) | |
58 | { | |
59 | string output = encode_url("http://www.google.com/<script>"); | |
60 | BOOST_CHECK_EQUAL(string("http%3A%2F%2Fwww%2Egoogle%2Ecom%2F%3Cscript%3E"), | |
61 | output); | |
62 | } | |
63 | ||
09ca2cbf | 64 | BOOST_AUTO_TEST_SUITE_END() |