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
86ee2bca
Commit
86ee2bca
authored
Jul 23, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release'
Conflicts: lms/djangoapps/courseware/tests/test_views.py
parents
077f0a2a
09dc4683
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
8 deletions
+32
-8
lms/djangoapps/courseware/tests/test_views.py
+26
-0
lms/djangoapps/courseware/views.py
+5
-7
lms/templates/courseware/submission_history.html
+1
-1
No files found.
lms/djangoapps/courseware/tests/test_views.py
View file @
86ee2bca
...
@@ -6,9 +6,12 @@ from django.http import Http404
...
@@ -6,9 +6,12 @@ from django.http import Http404
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.test.client
import
RequestFactory
from
django.test.client
import
RequestFactory
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
import
courseware.views
as
views
import
courseware.views
as
views
...
@@ -161,3 +164,26 @@ class ViewsTestCase(TestCase):
...
@@ -161,3 +164,26 @@ class ViewsTestCase(TestCase):
# generate/store a real password.
# generate/store a real password.
self
.
assertEquals
(
chat_settings
[
'password'
],
"johndoe@
%
s"
%
domain
)
self
.
assertEquals
(
chat_settings
[
'password'
],
"johndoe@
%
s"
%
domain
)
def
test_submission_history_xss
(
self
):
# log into a staff account
admin
=
AdminFactory
()
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'test'
)
# try it with an existing user and a malicious location
url
=
reverse
(
'submission_history'
,
kwargs
=
{
'course_id'
:
self
.
course_id
,
'student_username'
:
'dummy'
,
'location'
:
'<script>alert("hello");</script>'
})
response
=
self
.
client
.
get
(
url
)
self
.
assertFalse
(
'<script>'
in
response
.
content
)
# try it with a malicious user and a non-existent location
url
=
reverse
(
'submission_history'
,
kwargs
=
{
'course_id'
:
self
.
course_id
,
'student_username'
:
'<script>alert("hello");</script>'
,
'location'
:
'dummy'
})
response
=
self
.
client
.
get
(
url
)
self
.
assertFalse
(
'<script>'
in
response
.
content
)
lms/djangoapps/courseware/views.py
View file @
86ee2bca
...
@@ -14,6 +14,7 @@ from django.shortcuts import redirect
...
@@ -14,6 +14,7 @@ from django.shortcuts import redirect
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
django_future.csrf
import
ensure_csrf_cookie
from
django_future.csrf
import
ensure_csrf_cookie
from
django.views.decorators.cache
import
cache_control
from
django.views.decorators.cache
import
cache_control
from
markupsafe
import
escape
from
courseware
import
grades
from
courseware
import
grades
from
courseware.access
import
has_access
from
courseware.access
import
has_access
...
@@ -774,19 +775,16 @@ def submission_history(request, course_id, student_username, location):
...
@@ -774,19 +775,16 @@ def submission_history(request, course_id, student_username, location):
module_state_key
=
location
,
module_state_key
=
location
,
student_id
=
student
.
id
)
student_id
=
student
.
id
)
except
User
.
DoesNotExist
:
except
User
.
DoesNotExist
:
return
HttpResponse
(
"User {0} does not exist."
.
format
(
student_username
))
return
HttpResponse
(
escape
(
"User {0} does not exist."
.
format
(
student_username
)
))
except
StudentModule
.
DoesNotExist
:
except
StudentModule
.
DoesNotExist
:
return
HttpResponse
(
"{0} has never accessed problem {1}"
return
HttpResponse
(
escape
(
"{0} has never accessed problem {1}"
.
format
(
student_username
,
location
)))
.
format
(
student_username
,
location
))
history_entries
=
StudentModuleHistory
.
objects
\
history_entries
=
StudentModuleHistory
.
objects
.
filter
(
student_module
=
student_module
)
.
order_by
(
'-id'
)
.
filter
(
student_module
=
student_module
)
.
order_by
(
'-id'
)
# If no history records exist, let's force a save to get history started.
# If no history records exist, let's force a save to get history started.
if
not
history_entries
:
if
not
history_entries
:
student_module
.
save
()
student_module
.
save
()
history_entries
=
StudentModuleHistory
.
objects
\
history_entries
=
StudentModuleHistory
.
objects
.
filter
(
student_module
=
student_module
)
.
order_by
(
'-id'
)
.
filter
(
student_module
=
student_module
)
.
order_by
(
'-id'
)
context
=
{
context
=
{
'history_entries'
:
history_entries
,
'history_entries'
:
history_entries
,
...
...
lms/templates/courseware/submission_history.html
View file @
86ee2bca
<
%
import
json
%
>
<
%
import
json
%
>
<h3>
${username
} > ${course_id} > ${location
}
</h3>
<h3>
${username
| h} > ${course_id | h} > ${location | h
}
</h3>
% for i, entry in enumerate(history_entries):
% for i, entry in enumerate(history_entries):
<hr/>
<hr/>
...
...
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