diff --git a/common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee b/common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee index 9c42456d8668d2002268395c0ede5da83ef49a6d..a6d018b9bfbfda61678ef44f702dea9ad2014284 100644 --- a/common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee +++ b/common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee @@ -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") diff --git a/common/static/coffee/src/discussion/views/discussion_thread_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_view.coffee index 5d312051edf5ee85b416cd37db448bea0ffa6fff..eacbd5e866e324d94ab542ed92eba1d7c674b329 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_view.coffee @@ -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() diff --git a/lms/templates/instructor/instructor_dashboard_2/e-commerce.html b/lms/templates/instructor/instructor_dashboard_2/e-commerce.html index 055256f68bcaa714bcc6fedcf1e3598c5041c718..ba306a323d0990d5d00bf62722c990e705216c8d 100644 --- a/lms/templates/instructor/instructor_dashboard_2/e-commerce.html +++ b/lms/templates/instructor/instructor_dashboard_2/e-commerce.html @@ -99,7 +99,6 @@ <tr class="coupons-headings"> <th class="c_code">${_("Code")}</th> <th class="c_dsc">${_("Description")}</th> - <th class="c_course_id">${_("Course_id")}</th> <th class="c_discount">${_("Discount (%)")}</th> <th class="c_count">${_("Count")}</th> <th class="c_action">${_("Actions")}</th> @@ -114,7 +113,6 @@ %endif <td>${coupon.code}</td> <td>${coupon.description}</td> - <td>${coupon.course_id.to_deprecated_string()}</td> <td>${coupon.percentage_discount}</td> <td> ${ coupon.couponredemption_set.all().count() } diff --git a/lms/templates/shoppingcart/receipt.html b/lms/templates/shoppingcart/receipt.html index f86df03bae803564f0ecee505db47f00a4dcf0db..7a35bc014fd9806e2f36942872304ed0078f1105 100644 --- a/lms/templates/shoppingcart/receipt.html +++ b/lms/templates/shoppingcart/receipt.html @@ -1,6 +1,7 @@ <%! from django.utils.translation import ugettext as _ %> <%! from django.core.urlresolvers import reverse %> <%! from django.conf import settings %> +<%! from microsite_configuration import microsite %> <%inherit file="../main.html" /> @@ -22,7 +23,7 @@ <section class="wrapper cart-list"> <div class="wrapper-content-main"> <article class="content-main"> - <h1>${_(settings.PLATFORM_NAME + " (" + settings.SITE_NAME + ")" + " Electronic Receipt")}</h1> + <h1>${_("{platform_name} ({site_name}) Electronic Receipt").format(platform_name=microsite.get_value('platform_name', settings.PLATFORM_NAME), site_name=microsite.get_value('SITE_NAME', settings.SITE_NAME))}</h1> <hr /> <table class="order-receipt">