Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

#11358 closed defect (fixed)

add_script_data with U+2028/U+2029 characters lead a SyntaxError on Python 2.4/2.5

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 0.12.6
Component: general Version: 0.12-stable
Severity: normal Keywords:
Cc:
Release Notes:

Fix to_json, to_js_string and javascript_quote to escape line terminators U+2028 and U+2029 characters to avoid a SyntaxError in javascript

API Changes:

Description

In ECMA script, U+000a, U+000d, U+2028 and U+2029 characters are considers to be line terminators. json library is Therefore, we should escape those characters while passing to add_script_data, to_json, javascript_quote and to_js_string.

If Python 2.6+ which json library is available, the issue doesn't happen.

Adding the following

add_script_data(req, {'test': u'\u2029'})

… leads the following error in browser.

Uncaught SyntaxError: Unexpected token ILLEGAL

See http://bclary.com/2004/11/07/#a-7.3

Attachments (1)

unicode-line-terminators.diff (2.9 KB ) - added by Jun Omae 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by Jun Omae

comment:1 Changed 5 years ago by Jun Omae

Owner: set to Jun Omae
Status: newassigned

Proposed fix can be found in unicode-line-terminators.diff.

comment:2 Changed 5 years ago by Jun Omae

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [12241] and merged in [12242,12243].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.