Merge pull request #2285 from andreacorbellini/2263-handle-invalid-refs

Fix utils.truncate_html_words() to work with invalid HTML references
This commit is contained in:
Justin Mayer 2018-07-04 18:28:17 +02:00 committed by GitHub
commit b4d5e4285e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 10 deletions

View file

@ -217,6 +217,20 @@ class TestUtils(LoggedTestCase):
utils.truncate_html_words("∫dx " * 100, 20),
"∫dx " * 20 + '')
# Words with invalid or broken HTML references.
self.assertEqual(
utils.truncate_html_words('&invalid;', 20), '&invalid;')
self.assertEqual(
utils.truncate_html_words('�', 20), '�')
self.assertEqual(
utils.truncate_html_words('�', 20), '�')
self.assertEqual(
utils.truncate_html_words('&mdash text', 20), '&mdash text')
self.assertEqual(
utils.truncate_html_words('&#1234 text', 20), '&#1234 text')
self.assertEqual(
utils.truncate_html_words('&#xabc text', 20), '&#xabc text')
def test_process_translations(self):
fr_articles = []
en_articles = []