コード例 #1
0
ファイル: escape_test.py プロジェクト: genelee/anzu
 def test_xhtml_escape(self):
     tests = [
         ("<foo>", "&lt;foo&gt;"),
         (u"<foo>", u"&lt;foo&gt;"),
         (b("<foo>"), b("&lt;foo&gt;")),
         ("<>&\"", "&lt;&gt;&amp;&quot;"),
         ("&amp;", "&amp;amp;"),
     ]
     for unescaped, escaped in tests:
         self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped))
         self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
コード例 #2
0
ファイル: escape_test.py プロジェクト: wmark/anzu
    def test_xhtml_escape(self):
        tests = [
            ("<foo>", "&lt;foo&gt;"),
            (u"<foo>", u"&lt;foo&gt;"),
            (b("<foo>"), b("&lt;foo&gt;")),

            ("<>&\"", "&lt;&gt;&amp;&quot;"),
            ("&amp;", "&amp;amp;"),
            ]
        for unescaped, escaped in tests:
            self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped))
            self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
コード例 #3
0
ファイル: s3server.py プロジェクト: wmark/anzu
 def _render_parts(self, value, parts=[]):
     if isinstance(value, (unicode, bytes_type)):
         parts.append(escape.xhtml_escape(value))
     elif isinstance(value, int) or isinstance(value, long):
         parts.append(str(value))
     elif isinstance(value, datetime.datetime):
         parts.append(value.strftime("%Y-%m-%dT%H:%M:%S.000Z"))
     elif isinstance(value, dict):
         for name, subvalue in value.iteritems():
             if not isinstance(subvalue, list):
                 subvalue = [subvalue]
             for subsubvalue in subvalue:
                 parts.append('<' + escape.utf8(name) + '>')
                 self._render_parts(subsubvalue, parts)
                 parts.append('</' + escape.utf8(name) + '>')
     else:
         raise Exception("Unknown S3 value type %r", value)
コード例 #4
0
 def _render_parts(self, value, parts=[]):
     if isinstance(value, (unicode, bytes_type)):
         parts.append(escape.xhtml_escape(value))
     elif isinstance(value, int) or isinstance(value, long):
         parts.append(str(value))
     elif isinstance(value, datetime.datetime):
         parts.append(value.strftime("%Y-%m-%dT%H:%M:%S.000Z"))
     elif isinstance(value, dict):
         for name, subvalue in value.iteritems():
             if not isinstance(subvalue, list):
                 subvalue = [subvalue]
             for subsubvalue in subvalue:
                 parts.append('<' + escape.utf8(name) + '>')
                 self._render_parts(subsubvalue, parts)
                 parts.append('</' + escape.utf8(name) + '>')
     else:
         raise Exception("Unknown S3 value type %r", value)
コード例 #5
0
ファイル: escape_test.py プロジェクト: genelee/anzu
 def test_escape_return_types(self):
     # On python2 the escape methods should generally return the same
     # type as their argument
     self.assertEqual(type(xhtml_escape("foo")), str)
     self.assertEqual(type(xhtml_escape(u"foo")), unicode)
コード例 #6
0
ファイル: escape_test.py プロジェクト: wmark/anzu
 def test_escape_return_types(self):
     # On python2 the escape methods should generally return the same
     # type as their argument
     self.assertEqual(type(xhtml_escape("foo")), str)
     self.assertEqual(type(xhtml_escape(u"foo")), unicode)