diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 08ce492..aab1bd7 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -2245,6 +2245,7 @@ def add_token_to_user(session, project, acls, username): return 'Token created' + def text2markdown(text): """ Simple text to html converter using the markdown library. """ @@ -2263,6 +2264,18 @@ def text2markdown(text): return '' + +def filter_img_src(name, value): + ''' Filter in img html tags images coming from a different domain. ''' + if name in ('alt', 'height', 'width', 'class'): + return True + if name == 'src': + p = urlparse.urlparse(value) + return (not p.netloc) \ + or p.netloc == urlparse.urlparse(APP.config['APP_URL']).netloc + return False + + def clean_input(text): """ For a given html text, escape everything we do not want to support to avoid potential security breach. diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 81f0d73..9b096d5 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -287,17 +287,6 @@ def insert_div(content): return output -def filter_img_src(name, value): - ''' Filter in img html tags images coming from a different domain. ''' - if name in ('alt', 'height', 'width', 'class'): - return True - if name == 'src': - p = urlparse.urlparse(value) - return (not p.netloc) \ - or p.netloc == urlparse.urlparse(APP.config['APP_URL']).netloc - return False - - @APP.template_filter('noJS') def no_js(content): """ Template filter replacing