From 4eb5a22a111a05794774f0437864ace387aa4689 Mon Sep 17 00:00:00 2001 From: AliAkbar Date: Mon, 25 Sep 2023 00:06:53 +0500 Subject: [PATCH] fix: add XSS checks to validation for abbr attributes --- i18n/validate.py | 10 ++++++++-- requirements/base.in | 1 + requirements/base.txt | 3 +++ requirements/common_constraints.txt | 5 ----- tests/data/validation_problems.po | 4 ++++ tests/test_validate.py | 6 ++++++ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/i18n/validate.py b/i18n/validate.py index 3d84ef55..aa33d788 100644 --- a/i18n/validate.py +++ b/i18n/validate.py @@ -9,11 +9,12 @@ import textwrap import polib +from lxml.html import clean +from i18n import Runner +from i18n.converter import Converter from i18n.dummy import is_format_message from i18n.execute import call -from i18n.converter import Converter -from i18n import Runner log = logging.getLogger(__name__) @@ -97,6 +98,11 @@ def is_linguistic_tag(tag): if tag.startswith("&"): return True if any(x in tag for x in ["", ""]): + if "4.0.0 isn't yet compatible with many tox plugins, causing CI failures in almost all repos. # Details can be found in this discussion: https://github.com/tox-dev/tox/discussions/1810 tox<4.0.0 - -# edx-sphinx-theme is not compatible with latest Sphinx==6.0.0 version -# Pinning Sphinx version unless the compatibility issue gets resolved -# For details, see issue https://github.com/openedx/edx-sphinx-theme/issues/197 -sphinx<6.0.0 diff --git a/tests/data/validation_problems.po b/tests/data/validation_problems.po index ebc36b1c..890a6969 100644 --- a/tests/data/validation_problems.po +++ b/tests/data/validation_problems.po @@ -79,3 +79,7 @@ msgstr "Look -- a dog!" # could come-and-go with translations msgid "The CIA said so" msgstr "The secret agency said so" + +# may contain cross-site script attack which is usually skipped from validation +msgid "No tags" +msgstr "Added XSS tag CSS" diff --git a/tests/test_validate.py b/tests/test_validate.py index f14c087a..92d3dace 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -59,6 +59,12 @@ '"{nomx}" added', ), ('Empty translation', 'This string should not be empty'), + ( + 'Different tags in source and translation', + 'No tags', + "Added XSS tag CSS", + '"" added' + ), ]