From 4a99d313bfb2a226e6777a39a9a8588106f42685 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 21 Sep 2010 09:47:45 -0500 Subject: Allow serving jQuery via HTTPS if secure request detected Handles the concerns in FS#19045. Signed-off-by: Dan McGee --- main/templatetags/cdn.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py index fdb1be07..ef6bb144 100644 --- a/main/templatetags/cdn.py +++ b/main/templatetags/cdn.py @@ -9,9 +9,14 @@ def jquery(parser, token): class JQueryNode(template.Node): def render(self, context): + # if we have the request in context, we can check if it is secure and + # serve content from HTTPS instead. + secure = 'request' in context and context['request'].is_secure() version = '1.4.2' oncdn = getattr(settings, 'CDN_ENABLED', True) - if oncdn: + if oncdn and secure: + jquery = 'https://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js' % version + elif oncdn: jquery = 'http://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js' % version else: jquery = '/media/jquery-%s.min.js' % version -- cgit v1.2.3-54-g00ecf