summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-21 09:47:45 -0500
committerDan McGee <dan@archlinux.org>2010-09-21 09:47:45 -0500
commit4a99d313bfb2a226e6777a39a9a8588106f42685 (patch)
tree4a5f3b19f88de6ea42e21ebb7b91fe94af097e54
parent1b6cf5261c2a87c507fef290bf9d2af5606c8451 (diff)
Allow serving jQuery via HTTPS if secure request detected
Handles the concerns in FS#19045. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--main/templatetags/cdn.py7
1 files changed, 6 insertions, 1 deletions
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