1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 hatchling,
6 lxml,
7 lxml-html-clean,
8 beautifulsoup4,
9 pytestCheckHook,
10 pythonOlder,
11}:
12
13buildPythonPackage rec {
14 pname = "html-sanitizer";
15 version = "2.4.4";
16 pyproject = true;
17
18 disabled = pythonOlder "3.7";
19
20 src = fetchFromGitHub {
21 owner = "matthiask";
22 repo = "html-sanitizer";
23 rev = "refs/tags/${version}";
24 hash = "sha256-6OWFLsuefeDzQ1uHnLmboKDgrbY/xJCwqsSQlDaJlRs=";
25 };
26
27 nativeBuildInputs = [ hatchling ];
28
29 propagatedBuildInputs = [
30 lxml
31 lxml-html-clean
32 beautifulsoup4
33 ];
34
35 nativeCheckInputs = [ pytestCheckHook ];
36
37 pytestFlagsArray = [ "html_sanitizer/tests.py" ];
38
39 disabledTests = [
40 # Tests are sensitive to output
41 "test_billion_laughs"
42 "test_10_broken_html"
43 ];
44
45 pythonImportsCheck = [ "html_sanitizer" ];
46
47 meta = with lib; {
48 description = "Allowlist-based and very opinionated HTML sanitizer";
49 homepage = "https://github.com/matthiask/html-sanitizer";
50 changelog = "https://github.com/matthiask/html-sanitizer/blob/${version}/CHANGELOG.rst";
51 license = with licenses; [ bsd3 ];
52 maintainers = with maintainers; [ fab ];
53 };
54}