Merge remote-tracking branch 'origin/release' into adam/resolve-merge-conflicts

Conflicts:
	common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
This commit is contained in:
Adam Palay
2014-09-05 13:18:57 -04:00
10 changed files with 46 additions and 11 deletions

View File

@@ -566,6 +566,14 @@ class ModuleStoreReadBase(ModuleStoreRead):
finally:
self._end_bulk_operation(course_id)
@contextmanager
def bulk_temp_noop_operations(self, course_id):
"""
A hotfix noop b/c old mongo does not properly handle nested bulk operations and does unnecessary work
if the bulk operation only reads data. Replace with bulk_operations once fixed (or don't merge to master)
"""
yield
def _begin_bulk_operation(self, course_id):
"""
Begin a bulk write operation on course_id.

View File

@@ -68,7 +68,8 @@ def path_to_location(modulestore, usage_key):
newpath = (next_usage, path)
queue.append((parent, newpath))
with modulestore.bulk_operations(usage_key.course_key):
# FIXME replace with bulk_operations once it's fixed for old mongo
with modulestore.bulk_temp_noop_operations(usage_key.course_key):
if not modulestore.has_item(usage_key):
raise ItemNotFoundError(usage_key)

View File

@@ -901,7 +901,7 @@ class TestMixedModuleStore(unittest.TestCase):
# TODO: LMS-11220: Document why draft send count is 5
# TODO: LMS-11220: Document why draft find count is [19, 6]
# TODO: LMS-11220: Document why split find count is [2, 2]
@ddt.data(('draft', [21, 6], 0), ('split', [2, 2], 0))
@ddt.data(('draft', [18, 5], 0), ('split', [16, 6], 0)) # FIXME, replace w/ above when bulk reenabled
@ddt.unpack
def test_path_to_location(self, default_ms, num_finds, num_sends):
"""

View File

@@ -124,6 +124,32 @@ describe "DiscussionThreadView", ->
expect($(".post-body").text()).toEqual(expectedAbbreviation)
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", ->
beforeEach ->
@thread.set("thread_type", "question")

View File

@@ -62,7 +62,7 @@ if Backbone?
if event
event.preventDefault()
@$el.addClass("expanded")
@$el.find(".post-body").html(@model.get("body"))
@$el.find(".post-body").text(@model.get("body"))
@showView.convertMath()
@$el.find(".forum-thread-expand").hide()
@$el.find(".forum-thread-collapse").show()
@@ -74,7 +74,7 @@ if Backbone?
if event
event.preventDefault()
@$el.removeClass("expanded")
@$el.find(".post-body").html(@getAbbreviatedBody())
@$el.find(".post-body").text(@getAbbreviatedBody())
@showView.convertMath()
@$el.find(".forum-thread-expand").show()
@$el.find(".forum-thread-collapse").hide()