aboutsummaryrefslogtreecommitdiff
path: root/src/web/lib
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-07 00:00:37 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-07 00:00:37 +0200
commit181ee8dced7cccc687136c6f35faf2bff1d22d23 (patch)
tree7a2aea7553433957be0455694a7b39e91668dd42 /src/web/lib
parentcommit the session after deleting old articles. (diff)
parentFixed merge conflicts. (diff)
downloadnewspipe-181ee8dced7cccc687136c6f35faf2bff1d22d23.tar.gz
newspipe-181ee8dced7cccc687136c6f35faf2bff1d22d23.tar.bz2
newspipe-181ee8dced7cccc687136c6f35faf2bff1d22d23.zip
Fixed merge conflicts.
Diffstat (limited to 'src/web/lib')
-rw-r--r--src/web/lib/feed_utils.py14
-rw-r--r--src/web/lib/utils.py4
2 files changed, 16 insertions, 2 deletions
diff --git a/src/web/lib/feed_utils.py b/src/web/lib/feed_utils.py
index 80800bec..9925613f 100644
--- a/src/web/lib/feed_utils.py
+++ b/src/web/lib/feed_utils.py
@@ -1,3 +1,4 @@
+import html
import urllib
import logging
import requests
@@ -17,6 +18,19 @@ def is_parsing_ok(parsed_feed):
return parsed_feed['entries'] or not parsed_feed['bozo']
+def escape_keys(*keys):
+ def wrapper(func):
+ def metawrapper(*args, **kwargs):
+ result = func(*args, **kwargs)
+ for key in keys:
+ if key in result:
+ result[key] = html.unescape(result[key])
+ return result
+ return metawrapper
+ return wrapper
+
+
+@escape_keys('title', 'description')
def construct_feed_from(url=None, fp_parsed=None, feed=None, query_site=True):
requests_kwargs = {'headers': {'User-Agent': USER_AGENT}, 'verify': False}
if url is None and fp_parsed is not None:
diff --git a/src/web/lib/utils.py b/src/web/lib/utils.py
index 88d24ba5..f2bed3ff 100644
--- a/src/web/lib/utils.py
+++ b/src/web/lib/utils.py
@@ -9,12 +9,12 @@ from flask import request, url_for
logger = logging.getLogger(__name__)
-def default_handler(obj):
+def default_handler(obj, role='admin'):
"""JSON handler for default query formatting"""
if hasattr(obj, 'isoformat'):
return obj.isoformat()
if hasattr(obj, 'dump'):
- return obj.dump()
+ return obj.dump(role=role)
if isinstance(obj, (set, frozenset, types.GeneratorType)):
return list(obj)
if isinstance(obj, BaseException):
bgstack15