Skip to content
Snippets Groups Projects
Commit e205a697dcf7 authored by Bob Ippolito's avatar Bob Ippolito
Browse files

prevent </script> attack

git-svn-id: http://simplejson.googlecode.com/svn/trunk@23 a4795897-2c25-0410-b006-0d3caba88fa1
parent 903176097e79
No related branches found
No related tags found
No related merge requests found
......@@ -6,5 +6,5 @@
# this should match any kind of infinity
INFCHARS = re.compile(r'[infINF]')
ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]')
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
ESCAPE_ASCII = re.compile(r'([\\"/]|[^\ -~])')
ESCAPE_DCT = {
......@@ -10,4 +10,6 @@
ESCAPE_DCT = {
# escape all forward slashes to prevent </script> attack
'/': '\\/',
'\\': '\\\\',
'"': '\\"',
'\b': '\\b',
......
def test_script_close_attack():
import simplejson
res = simplejson.dumps('</script>')
assert '</script>' not in res
res = simplejson.dumps(simplejson.loads('"</script>"'))
assert '</script>' not in res
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment