From fc2a6f5adbab4228290de7393f7bfbd457a8bbd8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 20 2016 14:06:17 +0000 Subject: [PATCH 1/2] Allow the table to have set their class Fixes https://pagure.io/pagure/issue/1349 --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 07c9f96..29d58a4 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -2931,6 +2931,7 @@ def clean_input(text, ignore=None): ignore = [ignore] attrs = bleach.ALLOWED_ATTRIBUTES + attrs['table'] = ['class'] if not ignore or not 'img' in ignore: attrs['img'] = filter_img_src From 120564642e5088d6b36c19117784320f0ee898ee Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 20 2016 14:06:17 +0000 Subject: [PATCH 2/2] Copy the dict bleach.ALLOWED_ATTRIBUTES to reduce the risk to side-effects This should address @jcline's concern: Since `bleach.ALLOWED_ATTRIBUTES` is a mutable dictionary, this modifies `bleach.ALLOWED_ATTRIBUTES` itself, so anyone who is using this will have tables that allow the class attribute. --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 29d58a4..278fed7 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -2930,7 +2930,7 @@ def clean_input(text, ignore=None): if ignore and not isinstance(ignore, (tuple, set, list)): ignore = [ignore] - attrs = bleach.ALLOWED_ATTRIBUTES + attrs = bleach.ALLOWED_ATTRIBUTES.copy() attrs['table'] = ['class'] if not ignore or not 'img' in ignore: attrs['img'] = filter_img_src