memtimintursun / aspjson

Automatically exported from code.google.com/p/aspjson
0 stars 0 forks source link

jsEncode can produce strings that raise "Unterminated String Constant" errors #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a string element to the JSON collection that ends with Carriage
Return + Line Feed.
2. Attempt to use the toJSON'ed output of the JSON object in JavaScript.
The result is that the string value ends in "\r\n", however an
"Unterminated String Constant" error occurs.
3. Manually removing the \r\n sequence from the JSON output allows the code
to complete without error.
4. Based on guidance from http://planetlotus.org/profiles/wohill_53390,
double-escaping the \r\n to \\r\\n also allows the code to complete without
error.

What is the expected output? What do you see instead?
Based on http://planetlotus.org/profiles/wohill_53390, the expected output
from including a CR + LF sequence in a JSON string is \\r\\n. ASPJSON
outputs \r\n.

What version of the product are you using? On what operating system?
Server: ASPJSON 2.0.2 on IIS for Windows XP SP2
Client: Firefox 3.0.14 on Windows XP SP2

Please provide any additional information below.
ASPJSON 2.0.2 jsEncode can be modified to produce the required output by
inserting the following code at line 77:
    if (c = Chr(13) or c = Chr(10)) then
        jsEncode = jsEncode & "\"
    end if

Unsure whether this issue affects CR+LF sequences not at the end of the
string, nor other sequences that need to be escaped with a \ (e.g. \' \" etc)

Original issue reported on code.google.com by bra...@gmail.com on 24 Sep 2009 at 3:56

GoogleCodeExporter commented 8 years ago
This is a browser bug like Internet Explorer suck. Non acceptable solution.

Original comment by tugrulto...@gmail.com on 8 Nov 2009 at 7:35