From 6cc3e7eb93efdaffa36b5ab1cf7773de21b45810 Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 28 Jun 2014 01:20:47 +0200 Subject: [PATCH] Fix :callback and add content-type --- morss/morss.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/morss/morss.py b/morss/morss.py index 8c2f130..8835d80 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -693,8 +693,11 @@ def After(rss, options): if item.content: item.content = conv.handle(item.content) - if options.callback and re.match(r'^[a-zA-Z0-9\.]+$', options.callback) is not None: - return '%s(%s)' % (options.callback, rss.tojson()) + if options.callback: + if re.match(r'^[a-zA-Z0-9\.]+$', options.callback) is not None: + return '%s(%s)' % (options.callback, rss.tojson()) + else: + raise MorssException('Invalid callback var name') elif options.json: if options.indent: return rss.tojson(indent=4) @@ -768,6 +771,8 @@ def cgi_app(environ, start_response): headers['content-type'] = 'text/plain' elif options.json: headers['content-type'] = 'application/json' + elif options.callback: + headers['content-type'] = 'application/javascript' elif options.csv: headers['content-type'] = 'text/csv' headers['content-disposition'] = 'attachment; filename="feed.csv"'