Commit c9b0e12d by Adam Palay

use markupspace for escaping

parent 91ae60f5
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
This module contains celery task functions for handling the sending of bulk email This module contains celery task functions for handling the sending of bulk email
to a course. to a course.
""" """
import cgi
from collections import Counter from collections import Counter
import json import json
import logging import logging
...@@ -25,6 +24,7 @@ from boto.ses.exceptions import ( ...@@ -25,6 +24,7 @@ from boto.ses.exceptions import (
SESIllegalAddressError, SESIllegalAddressError,
) )
from boto.exception import AWSConnectionError from boto.exception import AWSConnectionError
from markupsafe import escape
from celery import task, current_task # pylint: disable=no-name-in-module from celery import task, current_task # pylint: disable=no-name-in-module
from celery.states import SUCCESS, FAILURE, RETRY # pylint: disable=no-name-in-module, import-error from celery.states import SUCCESS, FAILURE, RETRY # pylint: disable=no-name-in-module, import-error
...@@ -434,7 +434,7 @@ def _get_source_address(course_id, course_title, truncate=True): ...@@ -434,7 +434,7 @@ def _get_source_address(course_id, course_title, truncate=True):
# It seems that this value is also escaped when set out to amazon, judging # It seems that this value is also escaped when set out to amazon, judging
# from our logs # from our logs
escaped_encoded_from_addr = cgi.escape(encoded_from_addr) escaped_encoded_from_addr = escape(encoded_from_addr)
if len(escaped_encoded_from_addr) >= 320 and truncate: if len(escaped_encoded_from_addr) >= 320 and truncate:
from_addr = format_address(course_name) from_addr = format_address(course_name)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
""" """
Unit tests for sending course email Unit tests for sending course email
""" """
import cgi
import json import json
from markupsafe import escape
from mock import patch, Mock from mock import patch, Mock
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
import os import os
...@@ -344,7 +344,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase) ...@@ -344,7 +344,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
__, encoded_unexpected_from_addr = forbid_multi_line_headers( __, encoded_unexpected_from_addr = forbid_multi_line_headers(
"from", unexpected_from_addr, 'utf-8' "from", unexpected_from_addr, 'utf-8'
) )
escaped_encoded_unexpected_from_addr = cgi.escape(encoded_unexpected_from_addr) escaped_encoded_unexpected_from_addr = escape(encoded_unexpected_from_addr)
# it's shorter than 320 characters when just encoded # it's shorter than 320 characters when just encoded
self.assertEqual(len(encoded_unexpected_from_addr), 318) self.assertEqual(len(encoded_unexpected_from_addr), 318)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment