From 7f7643b7b41e478d354b3dc22e149a141e12e496 Mon Sep 17 00:00:00 2001 From: Daniel Clemente Laboreo Date: Tue, 26 Sep 2017 17:09:01 +0300 Subject: [PATCH 1/2] Encode URLs in shared links E.g. in "course-v1:edX+DemoX+Demo_Course" the "+" will become "%2B" --- .../courseware/course_about_sidebar_header.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lms/templates/courseware/course_about_sidebar_header.html b/lms/templates/courseware/course_about_sidebar_header.html index 027587ef3a..1e7a189dd1 100644 --- a/lms/templates/courseware/course_about_sidebar_header.html +++ b/lms/templates/courseware/course_about_sidebar_header.html @@ -1,5 +1,7 @@ <%namespace name='static' file='../static_content.html'/> <%! +import urllib + from django.utils.translation import ugettext as _ from django.core.urlresolvers import reverse from django.conf import settings @@ -24,7 +26,9 @@ from django.conf import settings account=static.get_value('course_about_twitter_account', settings.PLATFORM_TWITTER_ACCOUNT), url=u"http://{domain}{path}".format( domain=site_domain, - path=reverse('about_course', args=[course.id.to_deprecated_string()]) + path=urllib.quote_plus( + reverse('about_course', args=[course.id.to_deprecated_string()]) + ) ) ).replace(u" ", u"+") tweet_action = u"http://twitter.com/intent/tweet?text={tweet_text}".format(tweet_text=tweet_text) @@ -39,7 +43,9 @@ from django.conf import settings platform=platform_name, url=u"http://{domain}{path}".format( domain=site_domain, - path=reverse('about_course', args=[course.id.to_deprecated_string()]), + path=urllib.quote_plus( + reverse('about_course', args=[course.id.to_deprecated_string()]), + ) ) ) ).replace(u" ", u"%20") From adb6a5ac5542eaa561caf43a0ffdcd5f6284599d Mon Sep 17 00:00:00 2001 From: Daniel Clemente Laboreo Date: Tue, 26 Sep 2017 17:14:41 +0300 Subject: [PATCH 2/2] Use correct protocol in shared links (https/http) --- lms/templates/courseware/course_about_sidebar_header.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lms/templates/courseware/course_about_sidebar_header.html b/lms/templates/courseware/course_about_sidebar_header.html index 1e7a189dd1..0d6b1345af 100644 --- a/lms/templates/courseware/course_about_sidebar_header.html +++ b/lms/templates/courseware/course_about_sidebar_header.html @@ -16,6 +16,7 @@ from django.conf import settings ## want here (and on this whole page, really). <% site_domain = static.get_value('site_domain', settings.SITE_NAME) + site_protocol = 'https' if settings.HTTPS == 'on' else 'http' platform_name = static.get_platform_name() ## Translators: This text will be automatically posted to the student's @@ -24,7 +25,8 @@ from django.conf import settings number=course.number, title=course.display_name_with_default_escaped, account=static.get_value('course_about_twitter_account', settings.PLATFORM_TWITTER_ACCOUNT), - url=u"http://{domain}{path}".format( + url=u"{protocol}://{domain}{path}".format( + protocol=site_protocol, domain=site_domain, path=urllib.quote_plus( reverse('about_course', args=[course.id.to_deprecated_string()]) @@ -41,7 +43,8 @@ from django.conf import settings number=course.number, title=course.display_name_with_default_escaped, platform=platform_name, - url=u"http://{domain}{path}".format( + url=u"{protocol}://{domain}{path}".format( + protocol=site_protocol, domain=site_domain, path=urllib.quote_plus( reverse('about_course', args=[course.id.to_deprecated_string()]),