Show More
@@ -391,6 +391,8 b' class normcasespecs(object):' | |||
|
391 | 391 | _jsonmap[0x0c] = '\\f' |
|
392 | 392 | _jsonmap[0x0d] = '\\r' |
|
393 | 393 | _paranoidjsonmap = _jsonmap[:] |
|
394 | _paranoidjsonmap[0x3c] = '\\u003c' # '<' (e.g. escape "</script>") | |
|
395 | _paranoidjsonmap[0x3e] = '\\u003e' # '>' | |
|
394 | 396 | _jsonmap.extend(chr(x) for x in xrange(128, 256)) |
|
395 | 397 | |
|
396 | 398 | def jsonescape(s, paranoid=False): |
@@ -419,8 +421,8 b' def jsonescape(s, paranoid=False):' | |||
|
419 | 421 | >>> jsonescape('') |
|
420 | 422 | '' |
|
421 | 423 | |
|
422 |
If paranoid, non-ascii characters are also escaped. |
|
|
423 | web output. | |
|
424 | If paranoid, non-ascii and common troublesome characters are also escaped. | |
|
425 | This is suitable for web output. | |
|
424 | 426 | |
|
425 | 427 | >>> jsonescape('escape boundary: \\x7e \\x7f \\xc2\\x80', paranoid=True) |
|
426 | 428 | 'escape boundary: ~ \\\\u007f \\\\u0080' |
@@ -430,6 +432,8 b' def jsonescape(s, paranoid=False):' | |||
|
430 | 432 | 'utf-8: caf\\\\u00e9' |
|
431 | 433 | >>> jsonescape('non-BMP: \\xf0\\x9d\\x84\\x9e', paranoid=True) |
|
432 | 434 | 'non-BMP: \\\\ud834\\\\udd1e' |
|
435 | >>> jsonescape('<foo@example.org>', paranoid=True) | |
|
436 | '\\\\u003cfoo@example.org\\\\u003e' | |
|
433 | 437 | ''' |
|
434 | 438 | |
|
435 | 439 | if paranoid: |
General Comments 0
You need to be logged in to leave comments.
Login now