From 09e1f9ed71910341b1e806466d70308162dbb832 Mon Sep 17 00:00:00 2001 From: Daniel Friedman Date: Thu, 21 May 2015 22:46:12 +0000 Subject: [PATCH] Fix XSS vulnerability in User Profile. TNL-2248 --- .../student_profile/learner_profile.html | 4 ++-- openedx/core/lib/json_utils.py | 22 +++++++++++++++++++ openedx/core/lib/tests/test_json_utils.py | 18 +++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 openedx/core/lib/json_utils.py create mode 100644 openedx/core/lib/tests/test_json_utils.py diff --git a/lms/templates/student_profile/learner_profile.html b/lms/templates/student_profile/learner_profile.html index 3d895ed744..ae6451d644 100644 --- a/lms/templates/student_profile/learner_profile.html +++ b/lms/templates/student_profile/learner_profile.html @@ -1,7 +1,7 @@ <%! import json %> <%! from django.core.urlresolvers import reverse %> <%! from django.utils.translation import ugettext as _ %> -<%! from xmodule.modulestore import EdxJSONEncoder %> +<%! from openedx.core.lib.json_utils import EscapedEdxJSONEncoder %> <%inherit file="/main.html" /> <%namespace name='static' file='/static_content.html'/> @@ -39,7 +39,7 @@ ': ''} + self.assertNotIn( + '', + json.dumps(malicious_json, cls=EscapedEdxJSONEncoder) + )