Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ccb07f1c
Commit
ccb07f1c
authored
Mar 03, 2016
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Monkey patch django.utils.http.is_safe_url for Django 1.8.10.
parent
516db0d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
cms/startup.py
+6
-1
common/djangoapps/monkey_patch/django_utils_http_is_safe_url.py
+30
-0
lms/startup.py
+6
-2
No files found.
cms/startup.py
View file @
ccb07f1c
...
...
@@ -9,7 +9,11 @@ settings.INSTALLED_APPS # pylint: disable=pointless-statement
from
openedx.core.lib.django_startup
import
autostartup
import
django
from
monkey_patch
import
third_party_auth
,
django_db_models_options
from
monkey_patch
import
(
third_party_auth
,
django_db_models_options
,
django_utils_http_is_safe_url
)
import
xmodule.x_module
import
cms.lib.xblock.runtime
...
...
@@ -23,6 +27,7 @@ def run():
"""
third_party_auth
.
patch
()
django_db_models_options
.
patch
()
django_utils_http_is_safe_url
.
patch
()
# Comprehensive theming needs to be set up before django startup,
# because modifying django template paths after startup has no effect.
...
...
common/djangoapps/monkey_patch/django_utils_http_is_safe_url.py
0 → 100644
View file @
ccb07f1c
"""
Monkey patch the is_safe_url method in django.utils.http for Django 1.8.10.
In that release, the method crashes when a bytestring, non-unicode string is passed-in
as the url.
Remove the monkey patch when the bug is fixed in a Django 1.8 release. Here's the bug:
https://code.djangoproject.com/ticket/26308
"""
from
django.utils
import
http
from
django.utils.encoding
import
force_text
def
patch
():
"""
Monkey patch the django.utils.http.is_safe_url function to convert the incoming
url and host parameters to unicode.
"""
def
create_is_safe_url_wrapper
(
wrapped_func
):
# pylint: disable=missing-docstring
def
_wrap_is_safe_url
(
*
args
,
**
kwargs
):
def
_conv_text
(
value
):
return
None
if
value
is
None
else
force_text
(
value
)
return
wrapped_func
(
# Converted *args.
*
tuple
(
map
(
_conv_text
,
args
)),
# Converted **kwargs.
**
{
key
:
_conv_text
(
value
)
for
key
,
value
in
kwargs
.
items
()}
)
return
_wrap_is_safe_url
http
.
is_safe_url
=
create_is_safe_url_wrapper
(
http
.
is_safe_url
)
lms/startup.py
View file @
ccb07f1c
...
...
@@ -12,8 +12,11 @@ from openedx.core.lib.django_startup import autostartup
import
edxmako
import
logging
import
analytics
from
monkey_patch
import
third_party_auth
,
django_db_models_options
from
monkey_patch
import
(
third_party_auth
,
django_db_models_options
,
django_utils_http_is_safe_url
)
import
xmodule.x_module
import
lms_xblock.runtime
...
...
@@ -30,6 +33,7 @@ def run():
"""
third_party_auth
.
patch
()
django_db_models_options
.
patch
()
django_utils_http_is_safe_url
.
patch
()
# To override the settings before executing the autostartup() for python-social-auth
if
settings
.
FEATURES
.
get
(
'ENABLE_THIRD_PARTY_AUTH'
,
False
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment