def test_allowed_tags(self, get_outgoing_url_mock): get_outgoing_url_mock.return_value = 'http://external.url' s = u'<a href="http://example.com">bar</a>' x = LinkifiedTranslation(localized_string=s) doc = pq(x.__html__()) links = doc('a[href="http://external.url"][rel="nofollow"]') assert links[0].text == 'bar'
def test_forbidden_tags(self): s = u'<script>some naughty xss</script> <b>bold</b>' x = LinkifiedTranslation(localized_string=s) eq_( x.__html__(), '<script>some naughty xss</script> ' '<b>bold</b>')
def test_allowed_tags(self, get_outgoing_url_mock): get_outgoing_url_mock.return_value = 'http://external.url' s = u'<a href="http://example.com">bar</a>' x = LinkifiedTranslation(localized_string=s) eq_(x.__html__(), u'<a rel="nofollow" href="http://external.url">bar</a>')
def test_forbidden_tags(self): s = u'<script>some naughty xss</script> <b>bold</b>' x = LinkifiedTranslation(localized_string=s) eq_(x.__html__(), '<script>some naughty xss</script> ' '<b>bold</b>')
def test_allowed_tags(self, get_outgoing_url_mock): get_outgoing_url_mock.return_value = 'http://external.url' s = u'<a href="http://example.com">bar</a>' x = LinkifiedTranslation(localized_string=s) eq_(x.__html__(), u'<a href="http://external.url" rel="nofollow">bar</a>')