From 13df53316c64b87ba4bb8223b6db9ee2e0f7e4eb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 04 2019 19:04:58 +0000 Subject: Allow class on td and id and data-line-number on a This basically allows for elements added by the blame_loc filter to appear in the html since this html is passed through the bleach filter which limits the number of attributes an element can have. Incidentally, this commit also fixes the test suite Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/query.py b/pagure/lib/query.py index 1601de1..008e731 100644 --- a/pagure/lib/query.py +++ b/pagure/lib/query.py @@ -4368,8 +4368,9 @@ def clean_input(text, ignore=None): attrs["table"] = ["class"] attrs["span"] = ["class", "id"] attrs["div"] = ["class", "id"] - attrs["td"] = ["align"] + attrs["td"] = ["align", "class"] attrs["th"] = ["align"] + attrs["a"].extend(["id", "data-line-number"]) if not ignore or "img" not in ignore: # newer bleach need three args for attribute callable if tuple(bleach_v) >= (2, 0, 0): # pragma: no cover diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 31dcda6..4e2cbe3 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2877,10 +2877,12 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn('', output_text) - self.assertIn( + self.assertTrue( '', - output_text, + 'data-line-number="1">' in output_text + or + '' in output_text ) self.assertIn( '', output_text @@ -2899,10 +2901,12 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn('
 bar
', output_text) - self.assertIn( + self.assertTrue( '', - output_text, + 'data-line-number="1">' in output_text + or + '' in output_text ) self.assertIn( '', output_text @@ -2916,10 +2920,12 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn('
 bar
', output_text) - self.assertIn( + self.assertTrue( '', - output_text, + 'data-line-number="1">' in output_text + or + '' in output_text ) self.assertIn( '', output_text @@ -2966,10 +2972,12 @@ class PagureFlaskRepotests(tests.Modeltests): ) self.assertIn("  Ĺ ource", output_text) self.assertIn('
 bar
', output_text) - self.assertIn( + self.assertTrue( '', - output_text, + 'data-line-number="1">' in output_text + or + '' in output_text ) self.assertIn( '', output_text @@ -3006,10 +3014,12 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn('
Row 0
', output_text) - self.assertIn( + self.assertTrue( '', - output_text, + 'data-line-number="1">' in output_text + or + '' in output_text ) self.assertIn( '', @@ -3045,10 +3055,12 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn('
 barRow 0
', output_text) - self.assertIn( + self.assertTrue( '', - output_text, + 'data-line-number="1">' in output_text + or + '' in output_text ) self.assertIn( '', output_text
 bar