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
2bf9404d
Commit
2bf9404d
authored
Sep 05, 2014
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5098 from edx/adam/forums-script-escape
escape html for inline discussions (TNL-182)
parents
08f851aa
58553a7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee
+26
-0
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
+2
-2
No files found.
common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee
View file @
2bf9404d
...
@@ -124,6 +124,32 @@ describe "DiscussionThreadView", ->
...
@@ -124,6 +124,32 @@ describe "DiscussionThreadView", ->
expect
(
$
(
".post-body"
).
text
()).
toEqual
(
expectedAbbreviation
)
expect
(
$
(
".post-body"
).
text
()).
toEqual
(
expectedAbbreviation
)
expect
(
DiscussionThreadShowView
.
prototype
.
convertMath
).
toHaveBeenCalled
()
expect
(
DiscussionThreadShowView
.
prototype
.
convertMath
).
toHaveBeenCalled
()
it
"strips script tags appropriately"
,
->
DiscussionViewSpecHelper
.
setNextResponseContent
({
resp_total
:
0
,
children
:
[]})
longMaliciousBody
=
new
Array
(
100
).
join
(
"<script>alert('Until they think warm days will never cease');</script>
\n
"
)
@
thread
.
set
(
"body"
,
longMaliciousBody
)
maliciousAbbreviation
=
DiscussionUtil
.
abbreviateString
(
@
thread
.
get
(
'body'
),
140
)
# The nodes' html should be different than the strings, but
# their texts should be the same, indicating that they've been
# properly escaped. To be safe, make sure the string "<script"
# isn't present, either
@
view
.
render
()
expect
(
$
(
".post-body"
).
html
()).
not
.
toEqual
(
maliciousAbbreviation
)
expect
(
$
(
".post-body"
).
text
()).
toEqual
(
maliciousAbbreviation
)
expect
(
$
(
".post-body"
).
html
()).
not
.
toContain
(
"<script"
)
@
view
.
expand
()
expect
(
$
(
".post-body"
).
html
()).
not
.
toEqual
(
longMaliciousBody
)
expect
(
$
(
".post-body"
).
text
()).
toEqual
(
longMaliciousBody
)
expect
(
$
(
".post-body"
).
html
()).
not
.
toContain
(
"<script"
)
@
view
.
collapse
()
expect
(
$
(
".post-body"
).
html
()).
not
.
toEqual
(
maliciousAbbreviation
)
expect
(
$
(
".post-body"
).
text
()).
toEqual
(
maliciousAbbreviation
)
expect
(
$
(
".post-body"
).
html
()).
not
.
toContain
(
"<script"
)
describe
"for question threads"
,
->
describe
"for question threads"
,
->
beforeEach
->
beforeEach
->
@
thread
.
set
(
"thread_type"
,
"question"
)
@
thread
.
set
(
"thread_type"
,
"question"
)
...
...
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
2bf9404d
...
@@ -62,7 +62,7 @@ if Backbone?
...
@@ -62,7 +62,7 @@ if Backbone?
if
event
if
event
event
.
preventDefault
()
event
.
preventDefault
()
@
$el
.
addClass
(
"expanded"
)
@
$el
.
addClass
(
"expanded"
)
@
$el
.
find
(
".post-body"
).
html
(
@
model
.
get
(
"body"
))
@
$el
.
find
(
".post-body"
).
text
(
@
model
.
get
(
"body"
))
@
showView
.
convertMath
()
@
showView
.
convertMath
()
@
$el
.
find
(
".forum-thread-expand"
).
hide
()
@
$el
.
find
(
".forum-thread-expand"
).
hide
()
@
$el
.
find
(
".forum-thread-collapse"
).
show
()
@
$el
.
find
(
".forum-thread-collapse"
).
show
()
...
@@ -74,7 +74,7 @@ if Backbone?
...
@@ -74,7 +74,7 @@ if Backbone?
if
event
if
event
event
.
preventDefault
()
event
.
preventDefault
()
@
$el
.
removeClass
(
"expanded"
)
@
$el
.
removeClass
(
"expanded"
)
@
$el
.
find
(
".post-body"
).
html
(
@
getAbbreviatedBody
())
@
$el
.
find
(
".post-body"
).
text
(
@
getAbbreviatedBody
())
@
showView
.
convertMath
()
@
showView
.
convertMath
()
@
$el
.
find
(
".forum-thread-expand"
).
show
()
@
$el
.
find
(
".forum-thread-expand"
).
show
()
@
$el
.
find
(
".forum-thread-collapse"
).
hide
()
@
$el
.
find
(
".forum-thread-collapse"
).
hide
()
...
...
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