def test_truncate_purified_field_xss():
    s = 'safe <script>alert("omg")</script>'
    t = PurifiedTranslation(localized_string=s)
    env = jingo.get_env()
    actual = env.from_string('{{ s|truncate(100) }}').render({'s': t})
    eq_(actual, 'safe &lt;script&gt;alert("omg")&lt;/script&gt;')
    actual = env.from_string('{{ s|truncate(5) }}').render({'s': t})
    eq_(actual, 'safe ...')
Truncating should not introduce xss issues.
dataset/ETHPy150Open mozilla/addons-server/src/olympia/translations/tests/test_helpers.py/test_truncate_purified_field_xss