diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index dc794259..e32ed564 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -126,14 +126,14 @@ flags: re.DOTALL|re.I patterns: - <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:|data:)[\w|/]+ - - ]*?(?:\saction)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+ + - |\saction=(?:\"[^\"]*\"|'[^']*')).)*?\saction=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/|\s]+ - rule: name: J018 message: (Jinja) Internal links should use the {{ url_for() ... }} pattern. flags: re.DOTALL|re.I patterns: - <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:|data:)[\w|/]+ - - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+ + - |\saction=(?:\"[^\"]*\"|'[^']*')).)*?\saction=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/|\s]+ - rule: name: H019 message: Replace 'javascript:abc()' with on_ event and real url. diff --git a/tests/test_linter/test_django_linter.py b/tests/test_linter/test_django_linter.py index 46a80d6b..da73d588 100644 --- a/tests/test_linter/test_django_linter.py +++ b/tests/test_linter/test_django_linter.py @@ -279,6 +279,11 @@ ([]), id="DJ018_data_action", ), + pytest.param( + ('
'), + ([]), + id="DJ018_action_attr_url", + ), pytest.param( ("{% blah 'asdf %}"), ( diff --git a/tests/test_linter/test_jinja_linter.py b/tests/test_linter/test_jinja_linter.py index f57f2c22..3523ffa6 100644 --- a/tests/test_linter/test_jinja_linter.py +++ b/tests/test_linter/test_jinja_linter.py @@ -134,6 +134,11 @@ ([]), id="J018_attributes", ), + pytest.param( + ('
'), + ([]), + id="J018_action_attr_url", + ), pytest.param( ( "{% macro rendersubmit(buttons=[], class=\"\", index='', url='', that=\"\" , test='') -%}"