Python tornado.escape.xhtml_unescape() Examples
The following are 11
code examples of tornado.escape.xhtml_unescape().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.escape
, or try the search function
.
Example #1
Source File: escape_test.py From tornado-zh with MIT License | 5 votes |
def test_xhtml_escape(self): tests = [ ("<foo>", "<foo>"), (u("<foo>"), u("<foo>")), (b"<foo>", b"<foo>"), ("<>&\"'", "<>&"'"), ("&", "&amp;"), (u("<\u00e9>"), u("<\u00e9>")), (b"<\xc3\xa9>", b"<\xc3\xa9>"), ] for unescaped, escaped in tests: self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped)) self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
Example #2
Source File: escape_test.py From tornado-zh with MIT License | 5 votes |
def test_xhtml_unescape_numeric(self): tests = [ ('foo bar', 'foo bar'), ('foo bar', 'foo bar'), ('foo bar', 'foo bar'), ('foo઼bar', u('foo\u0abcbar')), ('foo&#xyz;bar', 'foo&#xyz;bar'), # invalid encoding ('foo&#;bar', 'foo&#;bar'), # invalid encoding ('foo&#x;bar', 'foo&#x;bar'), # invalid encoding ] for escaped, unescaped in tests: self.assertEqual(unescaped, xhtml_unescape(escaped))
Example #3
Source File: escape_test.py From tornado-zh with MIT License | 5 votes |
def test_xhtml_escape(self): tests = [ ("<foo>", "<foo>"), (u("<foo>"), u("<foo>")), (b"<foo>", b"<foo>"), ("<>&\"'", "<>&"'"), ("&", "&amp;"), (u("<\u00e9>"), u("<\u00e9>")), (b"<\xc3\xa9>", b"<\xc3\xa9>"), ] for unescaped, escaped in tests: self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped)) self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
Example #4
Source File: escape_test.py From tornado-zh with MIT License | 5 votes |
def test_xhtml_unescape_numeric(self): tests = [ ('foo bar', 'foo bar'), ('foo bar', 'foo bar'), ('foo bar', 'foo bar'), ('foo઼bar', u('foo\u0abcbar')), ('foo&#xyz;bar', 'foo&#xyz;bar'), # invalid encoding ('foo&#;bar', 'foo&#;bar'), # invalid encoding ('foo&#x;bar', 'foo&#x;bar'), # invalid encoding ] for escaped, unescaped in tests: self.assertEqual(unescaped, xhtml_unescape(escaped))
Example #5
Source File: parse_cases.py From viewfinder with Apache License 2.0 | 5 votes |
def parse_cases(filename): """Parses the fogbugz data in the file. Returns a list of (subject, assigned_to, body) tuples. """ results = [] tree = ElementTree.parse(filename) for case in tree.find('cases').findall('case'): subject = 'FB%s: %s' % (case.get('ixBug'), case.findtext('sTitle')) body = [] assigned_to = case.findtext('sPersonAssignedTo') body.append('Assigned to: %s' % assigned_to) body.append('Project: %s' % case.findtext('sProject')) body.append('Area: %s' % case.findtext('sArea')) body.append('Priority: %s (%s)' % (case.findtext('ixPriority'), case.findtext('sPriority'))) body.append('Category: %s' % case.findtext('sCategory')) body.append('') for event in case.find('events').findall('event'): body.append( '%s at %s' % (event.findtext('evtDescription'), event.findtext('dt'))) if event.findtext('s'): body.append('') body.append(event.findtext('s')) body.append('') if event.find('rgAttachments') is not None: for attachment in event.find('rgAttachments').findall('attachment'): body.append('Attachment: %s' % escape.xhtml_unescape(attachment.findtext('sURL'))) results.append((subject, USER_MAP[assigned_to], '\n'.join(body))) return results
Example #6
Source File: escape_test.py From viewfinder with Apache License 2.0 | 5 votes |
def test_xhtml_escape(self): tests = [ ("<foo>", "<foo>"), (u("<foo>"), u("<foo>")), (b"<foo>", b"<foo>"), ("<>&\"'", "<>&"'"), ("&", "&amp;"), (u("<\u00e9>"), u("<\u00e9>")), (b"<\xc3\xa9>", b"<\xc3\xa9>"), ] for unescaped, escaped in tests: self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped)) self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
Example #7
Source File: parse_cases.py From viewfinder with Apache License 2.0 | 5 votes |
def parse_cases(filename): """Parses the fogbugz data in the file. Returns a list of (subject, assigned_to, body) tuples. """ results = [] tree = ElementTree.parse(filename) for case in tree.find('cases').findall('case'): subject = 'FB%s: %s' % (case.get('ixBug'), case.findtext('sTitle')) body = [] assigned_to = case.findtext('sPersonAssignedTo') body.append('Assigned to: %s' % assigned_to) body.append('Project: %s' % case.findtext('sProject')) body.append('Area: %s' % case.findtext('sArea')) body.append('Priority: %s (%s)' % (case.findtext('ixPriority'), case.findtext('sPriority'))) body.append('Category: %s' % case.findtext('sCategory')) body.append('') for event in case.find('events').findall('event'): body.append( '%s at %s' % (event.findtext('evtDescription'), event.findtext('dt'))) if event.findtext('s'): body.append('') body.append(event.findtext('s')) body.append('') if event.find('rgAttachments') is not None: for attachment in event.find('rgAttachments').findall('attachment'): body.append('Attachment: %s' % escape.xhtml_unescape(attachment.findtext('sURL'))) results.append((subject, USER_MAP[assigned_to], '\n'.join(body))) return results
Example #8
Source File: escape_test.py From viewfinder with Apache License 2.0 | 5 votes |
def test_xhtml_escape(self): tests = [ ("<foo>", "<foo>"), (u("<foo>"), u("<foo>")), (b"<foo>", b"<foo>"), ("<>&\"'", "<>&"'"), ("&", "&amp;"), (u("<\u00e9>"), u("<\u00e9>")), (b"<\xc3\xa9>", b"<\xc3\xa9>"), ] for unescaped, escaped in tests: self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped)) self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
Example #9
Source File: escape_test.py From honeything with GNU General Public License v3.0 | 5 votes |
def test_xhtml_escape(self): tests = [ ("<foo>", "<foo>"), (u"<foo>", u"<foo>"), (b("<foo>"), b("<foo>")), ("<>&\"", "<>&""), ("&", "&amp;"), ] for unescaped, escaped in tests: self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped)) self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
Example #10
Source File: escape_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def test_xhtml_escape(self): tests = [ ("<foo>", "<foo>"), (u("<foo>"), u("<foo>")), (b"<foo>", b"<foo>"), ("<>&\"'", "<>&"'"), ("&", "&amp;"), (u("<\u00e9>"), u("<\u00e9>")), (b"<\xc3\xa9>", b"<\xc3\xa9>"), ] for unescaped, escaped in tests: self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped)) self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
Example #11
Source File: escape_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def test_xhtml_unescape_numeric(self): tests = [ ('foo bar', 'foo bar'), ('foo bar', 'foo bar'), ('foo bar', 'foo bar'), ('foo઼bar', u('foo\u0abcbar')), ('foo&#xyz;bar', 'foo&#xyz;bar'), # invalid encoding ('foo&#;bar', 'foo&#;bar'), # invalid encoding ('foo&#x;bar', 'foo&#x;bar'), # invalid encoding ] for escaped, unescaped in tests: self.assertEqual(unescaped, xhtml_unescape(escaped))