Skip to content

Commit

Permalink
Refs #34: Add a test for the <img> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Oct 31, 2023
1 parent e0937eb commit 74a7a59
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-builtin-literals
Expand All @@ -14,29 +14,29 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.13.0
rev: 1.15.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.272"
rev: "v0.1.3"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
rev: v3.0.3
hooks:
- id: prettier
args: [--list-different, --no-semi]
exclude: "^conf/|.*\\.html$"
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 0.11.2
rev: 1.3.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.13
rev: v0.15
hooks:
- id: validate-pyproject
19 changes: 19 additions & 0 deletions html_sanitizer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,22 @@ def test_invalid_attributes(self):

with self.assertRaisesRegex(TypeError, 'Tags in "empty", but not allowed:'):
Sanitizer({"tags": {"blub"}})

def test_img_tag(self):
sanitizer = Sanitizer(
{
"tags": {"p", "img"},
"empty": {"img"},
"separate": (),
"attributes": {"img": {"alt", "src"}},
}
)

entries = (
(
'<p><img src="hello.jpg" alt="hello" class="hello"></p>',
'<p><img src="hello.jpg" alt="hello"></p>',
),
)

self.run_tests(entries, sanitizer=sanitizer)

0 comments on commit 74a7a59

Please sign in to comment.