Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
9659f24d
Commit
9659f24d
authored
10 years ago
by
Mathew Peterson
Browse files
Options
Downloads
Plain Diff
Merge pull request #4133 from edx/mathewpeterson/fix_unicode_in_url_bug
404 error for unwanted unicode in url LMS-2488
parents
ca045aaa
c86cbe46
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/tests/test_views.py
+16
-0
16 additions, 0 deletions
lms/djangoapps/courseware/tests/test_views.py
lms/djangoapps/courseware/views.py
+6
-0
6 additions, 0 deletions
lms/djangoapps/courseware/views.py
with
22 additions
and
0 deletions
lms/djangoapps/courseware/tests/test_views.py
+
16
−
0
View file @
9659f24d
...
...
@@ -158,6 +158,22 @@ class ViewsTestCase(TestCase):
response
=
self
.
client
.
get
(
request_url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_unicode_handling_in_url
(
self
):
url_parts
=
[
'
/courses
'
,
self
.
course
.
id
.
to_deprecated_string
(),
self
.
chapter
.
location
.
name
,
self
.
section
.
location
.
name
,
'
1
'
]
for
idx
,
val
in
enumerate
(
url_parts
):
url_parts_copy
=
url_parts
[:]
url_parts_copy
[
idx
]
=
val
+
u
'
χ
'
request_url
=
'
/
'
.
join
(
url_parts_copy
)
response
=
self
.
client
.
get
(
request_url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_registered_for_course
(
self
):
self
.
assertFalse
(
views
.
registered_for_course
(
'
Basketweaving
'
,
None
))
mock_user
=
MagicMock
()
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/views.py
+
6
−
0
View file @
9659f24d
...
...
@@ -404,6 +404,12 @@ def index(request, course_id, chapter=None, section=None,
result
=
render_to_response
(
'
courseware/courseware.html
'
,
context
)
except
Exception
as
e
:
# Doesn't bar Unicode characters from URL, but if Unicode characters do
# cause an error it is a graceful failure.
if
isinstance
(
e
,
UnicodeEncodeError
):
raise
Http404
(
"
URL contains Unicode characters
"
)
if
isinstance
(
e
,
Http404
):
# let it propagate
raise
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment