fixed #116, added test

This commit is contained in:
Christopher Pickering 2021-10-14 09:17:31 +03:00
parent 17e29a79cf
commit 3ab0eab278
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
3 changed files with 13 additions and 2 deletions

View file

@ -4,6 +4,7 @@ Changelog
next release
-----------
- Added require_pragma option
- Updated DJ018 to catch ``data-src`` and ``action`` on inputs
0.5.7
-----

View file

@ -133,14 +133,14 @@
message: (Django) Internal links should use the {% url ... %} pattern.
flags: re.DOTALL|re.I
patterns:
- <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+
- <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+
- rule:
name: J018
message: (Jinja) Internal links should use the {{ url_for() ... }} pattern.
flags: re.DOTALL|re.I
patterns:
- <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+
- <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+
- rule:
name: H019

View file

@ -254,6 +254,16 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None:
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 0
# test data-src
write_to_file(
tmp_file.name,
b'<div class="em-ajaxLogs" data-src="/table/task/{{ t.id }}/log"></div>',
)
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 1
assert "D018 1:" in result.output
assert "J018 1:" in result.output
def test_H019(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b"<a href='javascript:abc()'>asdf</a>")