A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/simplejson/simplejson/commit/4989e693bab39b1ce5cf6fc0b21dbacd108c312c below:

Force unicode linebreak characters to be escaped (U+2028 and U+2029) · simplejson/simplejson@4989e69 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+15

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+15

-1

lines changed Original file line number Diff line number Diff line change

@@ -1,5 +1,7 @@

1 1

Version 2.1.7 released 2011-XX-XX

2 2 3 +

* Force unicode linebreak characters to be escaped (U+2028 and U+2029)

4 +

http://timelessrepo.com/json-isnt-a-javascript-subset

3 5

* Moved documentation from a git submodule to

4 6

http://simplejson.readthedocs.org/

5 7 Original file line number Diff line number Diff line change

@@ -13,7 +13,7 @@ def _import_speedups():

13 13 14 14

from simplejson.decoder import PosInf

15 15 16 -

ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')

16 +

ESCAPE = re.compile(ur'[\x00-\x1f\\"\b\f\n\r\t\u2028\u2029]')

17 17

ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')

18 18

HAS_UTF8 = re.compile(r'[\x80-\xff]')

19 19

ESCAPE_DCT = {

@@ -24,6 +24,8 @@ def _import_speedups():

24 24

'\n': '\\n',

25 25

'\r': '\\r',

26 26

'\t': '\\t',

27 +

u'\u2028': '\\u2028',

28 +

u'\u2029': '\\u2029',

27 29

}

28 30

for i in range(0x20):

29 31

#ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))

Original file line number Diff line number Diff line change

@@ -97,3 +97,13 @@ def test_ensure_ascii_false_bytestring_encoding(self):

97 97

self.assertEquals(json.dumps(doc2), doc_ascii)

98 98

self.assertEquals(json.dumps(doc1, ensure_ascii=False), doc_unicode)

99 99

self.assertEquals(json.dumps(doc2, ensure_ascii=False), doc_unicode)

100 + 101 +

def test_ensure_ascii_linebreak_encoding(self):

102 +

# http://timelessrepo.com/json-isnt-a-javascript-subset

103 +

s1 = u'\u2029\u2028'

104 +

s2 = s1.encode('utf8')

105 +

expect = '"\\u2029\\u2028"'

106 +

self.assertEquals(json.dumps(s1), expect)

107 +

self.assertEquals(json.dumps(s2), expect)

108 +

self.assertEquals(json.dumps(s1, ensure_ascii=False), expect)

109 +

self.assertEquals(json.dumps(s2, ensure_ascii=False), expect)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4