Beispiel #1
0
 def test_escapejs(self):
     self.assertEqual(escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027')
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'),
         '\\u005C : backslashes, too')
     self.assertEqual(escapejs_filter('and lots of whitespace: \r\n\t\v\f\b'),
         'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008')
     self.assertEqual(escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E')
     self.assertEqual(
         escapejs_filter('paragraph separator:\u2029and line separator:\u2028'),
         'paragraph separator:\\u2029and line separator:\\u2028')
Beispiel #2
0
 def test_escapejs(self):
     self.assertEqual(escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027')
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'),
         '\\u005C : backslashes, too')
     self.assertEqual(escapejs_filter('and lots of whitespace: \r\n\t\v\f\b'),
         'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008')
     self.assertEqual(escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E')
     self.assertEqual(
         escapejs_filter('paragraph separator:\u2029and line separator:\u2028'),
         'paragraph separator:\\u2029and line separator:\\u2028')
Beispiel #3
0
 def test_lazy_string(self):
     append_script = lazy(lambda string: r'<script>this</script>' + string,
                          str)
     self.assertEqual(
         escapejs_filter(append_script('whitespace: \r\n\t\v\f\b')),
         '\\u003Cscript\\u003Ethis\\u003C/script\\u003E'
         'whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008')
Beispiel #4
0
 def test_lazy_string(self):
     append_script = lazy(lambda string: r"<script>this</script>" + string, str)
     self.assertEqual(
         escapejs_filter(append_script("whitespace: \r\n\t\v\f\b")),
         "\\u003Cscript\\u003Ethis\\u003C/script\\u003E"
         "whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008",
     )
Beispiel #5
0
 def test_lazy_string(self):
     append_script = lazy(lambda string: r'<script>this</script>' + string, six.text_type)
     self.assertEqual(
         escapejs_filter(append_script('whitespace: \r\n\t\v\f\b')),
         '\\u003Cscript\\u003Ethis\\u003C/script\\u003E'
         'whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008'
     )
Beispiel #6
0
 def test_quotes(self):
     self.assertEqual(
         escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027',
     )
Beispiel #7
0
 def test_whitespace(self):
     self.assertEqual(
         escapejs_filter('and lots of whitespace: \r\n\t\v\f\b'),
         'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008',
     )
Beispiel #8
0
 def test_paragraph_separator(self):
     self.assertEqual(
         escapejs_filter("paragraph separator:\u2029and line separator:\u2028"),
         "paragraph separator:\\u2029and line separator:\\u2028",
     )
Beispiel #9
0
 def test_script(self):
     self.assertEqual(
         escapejs_filter(r"<script>and this</script>"),
         "\\u003Cscript\\u003Eand this\\u003C/script\\u003E",
     )
Beispiel #10
0
 def test_whitespace(self):
     self.assertEqual(
         escapejs_filter("and lots of whitespace: \r\n\t\v\f\b"),
         "and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008",
     )
Beispiel #11
0
 def test_backslashes(self):
     self.assertEqual(
         escapejs_filter(r"\ : backslashes, too"), "\\u005C : backslashes, too"
     )
Beispiel #12
0
 def test_quotes(self):
     self.assertEqual(
         escapejs_filter("\"double quotes\" and 'single quotes'"),
         "\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027",
     )
Beispiel #13
0
def escapejs(data):
    return escapejs_filter(data)
Beispiel #14
0
 def test_backslashes(self):
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'), '\\u005C : backslashes, too')
Beispiel #15
0
 def test_script(self):
     self.assertEqual(
         escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E',
     )
Beispiel #16
0
 def test_backslashes(self):
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'),
                      '\\u005C : backslashes, too')
Beispiel #17
0
 def test_quotes(self):
     self.assertEqual(
         escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027',
     )
Beispiel #18
0
 def test_paragraph_separator(self):
     self.assertEqual(
         escapejs_filter('paragraph separator:\u2029and line separator:\u2028'),
         'paragraph separator:\\u2029and line separator:\\u2028',
     )
Beispiel #19
0
 def test_script(self):
     self.assertEqual(
         escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E',
     )