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
0f789892
Commit
0f789892
authored
Sep 17, 2015
by
Peter Fogg
Committed by
Kevin Falcone
Sep 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape team name in screenreader text.
parent
dd7121f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
common/test/acceptance/tests/lms/test_teams.py
+33
-7
lms/djangoapps/teams/static/teams/js/views/team_card.js
+1
-1
No files found.
common/test/acceptance/tests/lms/test_teams.py
View file @
0f789892
...
@@ -8,9 +8,10 @@ import time
...
@@ -8,9 +8,10 @@ import time
from
dateutil.parser
import
parse
from
dateutil.parser
import
parse
import
ddt
import
ddt
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
selenium.common.exceptions
import
TimeoutException
from
uuid
import
uuid4
from
uuid
import
uuid4
from
..helpers
import
EventsTestMixin
,
UniqueCourseTest
from
..helpers
import
get_modal_alert
,
EventsTestMixin
,
UniqueCourseTest
from
...fixtures
import
LMS_BASE_URL
from
...fixtures
import
LMS_BASE_URL
from
...fixtures.course
import
CourseFixture
from
...fixtures.course
import
CourseFixture
from
...fixtures.discussion
import
(
from
...fixtures.discussion
import
(
...
@@ -60,18 +61,23 @@ class TeamsTabBase(EventsTestMixin, UniqueCourseTest):
...
@@ -60,18 +61,23 @@ class TeamsTabBase(EventsTestMixin, UniqueCourseTest):
'language'
:
'aa'
,
'language'
:
'aa'
,
'country'
:
'AF'
'country'
:
'AF'
}
}
response
=
self
.
course_fixture
.
session
.
post
(
teams
.
append
(
self
.
post_team_data
(
team
))
LMS_BASE_URL
+
'/api/team/v0/teams/'
,
data
=
json
.
dumps
(
team
),
headers
=
self
.
course_fixture
.
headers
)
# Sadly, this sleep is necessary in order to ensure that
# Sadly, this sleep is necessary in order to ensure that
# sorting by last_activity_at works correctly when running
# sorting by last_activity_at works correctly when running
# in Jenkins.
# in Jenkins.
time
.
sleep
(
time_between_creation
)
time
.
sleep
(
time_between_creation
)
teams
.
append
(
json
.
loads
(
response
.
text
))
return
teams
return
teams
def
post_team_data
(
self
,
team_data
):
"""Given a JSON representation of a team, post it to the server."""
response
=
self
.
course_fixture
.
session
.
post
(
LMS_BASE_URL
+
'/api/team/v0/teams/'
,
data
=
json
.
dumps
(
team_data
),
headers
=
self
.
course_fixture
.
headers
)
self
.
assertEqual
(
response
.
status_code
,
200
)
return
json
.
loads
(
response
.
text
)
def
create_membership
(
self
,
username
,
team_id
):
def
create_membership
(
self
,
username
,
team_id
):
"""Assign `username` to `team_id`."""
"""Assign `username` to `team_id`."""
response
=
self
.
course_fixture
.
session
.
post
(
response
=
self
.
course_fixture
.
session
.
post
(
...
@@ -838,6 +844,26 @@ class BrowseTeamsWithinTopicTest(TeamsTabBase):
...
@@ -838,6 +844,26 @@ class BrowseTeamsWithinTopicTest(TeamsTabBase):
with
self
.
assert_events_match_during
(
self
.
only_team_events
,
expected_events
=
events
):
with
self
.
assert_events_match_during
(
self
.
only_team_events
,
expected_events
=
events
):
self
.
browse_teams_page
.
visit
()
self
.
browse_teams_page
.
visit
()
def
test_team_name_xss
(
self
):
"""
Scenario: Team names should be HTML-escaped on the teams page
Given I am enrolled in a course with teams enabled
When I visit the Teams page for a topic, with a team name containing JS code
Then I should not see any alerts
"""
team
=
self
.
post_team_data
({
'course_id'
:
self
.
course_id
,
'topic_id'
:
self
.
topic
[
'id'
],
'name'
:
'<script>alert("XSS")</script>'
,
'description'
:
'Description'
,
'language'
:
'aa'
,
'country'
:
'AF'
})
with
self
.
assertRaises
(
TimeoutException
):
self
.
browser
.
get
(
self
.
browse_teams_page
.
url
)
alert
=
get_modal_alert
(
self
.
browser
)
alert
.
accept
()
@attr
(
'shard_5'
)
@attr
(
'shard_5'
)
class
TeamFormActions
(
TeamsTabBase
):
class
TeamFormActions
(
TeamsTabBase
):
...
...
lms/djangoapps/teams/static/teams/js/views/team_card.js
View file @
0f789892
...
@@ -135,7 +135,7 @@
...
@@ -135,7 +135,7 @@
actionContent
:
function
()
{
actionContent
:
function
()
{
return
interpolate
(
return
interpolate
(
gettext
(
'View %(span_start)s %(team_name)s %(span_end)s'
),
gettext
(
'View %(span_start)s %(team_name)s %(span_end)s'
),
{
span_start
:
'<span class="sr">'
,
team_name
:
this
.
teamModel
().
get
(
'name'
),
span_end
:
'</span>'
},
{
span_start
:
'<span class="sr">'
,
team_name
:
_
.
escape
(
this
.
teamModel
().
get
(
'name'
)
),
span_end
:
'</span>'
},
true
true
);
);
},
},
...
...
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