Exemplo n.º 1
0
def modify_message(msgobj):
    msg = getattr(msgobj, 'message', None)

    if msg is not None:
        # will fixup bad HTML like aim's <HTML><BODY> stuff
        msgobj.message = to_xhtml(msg)

    return msgobj
Exemplo n.º 2
0
def modify_message(msgobj):
    msg = getattr(msgobj, 'message', None)

    if msg is not None:
        # will fixup bad HTML like aim's <HTML><BODY> stuff
        msgobj.message = to_xhtml(msg)

    return msgobj
Exemplo n.º 3
0
    def test_html_and_body_tag_removed(self):
        'test AIM-style html junk removal'

        # tuples of (input, expected_output)
        fragments = [
            (u'<html><body bgcolor="#ff0000"><b>red <i>text</i></b></body></html>',
             u'<span style="background-color: #ff0000;"><b>red <i>text</i></b></span>'
             ),
            (u'<html><body>test</body></html>', u'test'),
            (u'<html>bare html</html>', u'bare html'),
        ]

        for original, expected in fragments:
            transformed = to_xhtml(original)
            self.expect_equal(expected, transformed)
Exemplo n.º 4
0
    def test_html_and_body_tag_removed(self):
        'test AIM-style html junk removal'

        # tuples of (input, expected_output)
        fragments = [
            (u'<html><body bgcolor="#ff0000"><b>red <i>text</i></b></body></html>',
             u'<span style="background-color: #ff0000;"><b>red <i>text</i></b></span>'),

            (u'<html><body>test</body></html>', u'test'),
            (u'<html>bare html</html>', u'bare html'),
        ]

        for original, expected in fragments:
            transformed = to_xhtml(original)
            self.expect_equal(expected, transformed)
Exemplo n.º 5
0
    def test_html_unharmed(self):
        'test that some text fragments remain untransformed'

        # these shouldn't change
        fragments = [
            '<b>test</b>',
            '<i>test</i>',
            'test',
            '     ',
            '',
            'test &amp; test',
        ]

        for fragment in fragments:
            transformed = to_xhtml(fragment)
            self.expect_equal(fragment, transformed)
Exemplo n.º 6
0
    def test_html_unharmed(self):
        'test that some text fragments remain untransformed'
        
        # these shouldn't change
        fragments = [
            '<b>test</b>',
            '<i>test</i>',
            'test',
            '     ',
            '',
            'test &amp; test',
        ]

        for fragment in fragments:
            transformed = to_xhtml(fragment)
            self.expect_equal(fragment, transformed)