Merge lp:~cjwatson/lazr.restful/remove-simplejson-workaround into lp:lazr.restful

Proposed by Colin Watson on 2018-11-15
Status: Merged
Merged at revision: 223
Proposed branch: lp:~cjwatson/lazr.restful/remove-simplejson-workaround
Merge into: lp:lazr.restful
Diff against target: 54 lines (+10/-8)
3 files modified
src/lazr/restful/NEWS.txt (+3/-0)
src/lazr/restful/docs/webservice-marshallers.txt (+4/-0)
src/lazr/restful/marshallers.py (+3/-8)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/remove-simplejson-workaround
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve on 2018-11-15
LAZR Developers 2018-11-15 Pending
Review via email: mp+358849@code.launchpad.net

Commit message

Fix interpretation of values from requests containing only whitespace.

Description of the change

The referenced simplejson bug was fixed in 2.1.0, which lazr.restful already requires.

To post a comment you must log in.
Natalia Bidart (nataliabidart) wrote :

15:33 < nessita> cjwatson, looks good to me, but of course you may need a lazr developer vote

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/NEWS.txt'
2--- src/lazr/restful/NEWS.txt 2018-10-01 08:55:53 +0000
3+++ src/lazr/restful/NEWS.txt 2018-11-15 15:31:17 +0000
4@@ -16,6 +16,9 @@
5 Generate IEntry subinterfaces with field ordering matching that in the
6 original interface.
7
8+Fixed bug 1803564: Values from requests that contain only whitespace are now
9+interpreted correctly.
10+
11 0.20.1 (2018-02-21)
12 ===================
13
14
15=== modified file 'src/lazr/restful/docs/webservice-marshallers.txt'
16--- src/lazr/restful/docs/webservice-marshallers.txt 2018-09-28 15:47:07 +0000
17+++ src/lazr/restful/docs/webservice-marshallers.txt 2018-11-15 15:31:17 +0000
18@@ -103,6 +103,10 @@
19 'False'
20 >>> marshaller.marshall_from_request("")
21 ''
22+ >>> marshaller.marshall_from_request(' ')
23+ ' '
24+ >>> marshaller.marshall_from_request('\n')
25+ '\n'
26 >>> marshaller.marshall_from_request(['value1', 'value2'])
27 ['value1', 'value2']
28
29
30=== modified file 'src/lazr/restful/marshallers.py'
31--- src/lazr/restful/marshallers.py 2016-02-17 01:07:21 +0000
32+++ src/lazr/restful/marshallers.py 2018-11-15 15:31:17 +0000
33@@ -156,18 +156,13 @@
34 v = value
35 if isinstance(v, str):
36 v = v.decode('utf8') # assume utf8
37- # XXX gary 2009-03-28
38- # The use of the enclosing brackets is a hack to work around
39- # simplejson bug 43:
40- # http://code.google.com/p/simplejson/issues/detail?id=43
41- v = simplejson.loads(u'[%s]' % (v,))
42+ elif not isinstance(v, unicode):
43+ v = unicode(v)
44+ value = simplejson.loads(v)
45 except (ValueError, TypeError):
46 # Pass the value as is. This saves client from having to encode
47 # strings.
48 pass
49- else:
50- # see comment about simplejson bug above
51- value = v[0]
52 if value is None:
53 return None
54 return self._marshall_from_request(value)

Subscribers

People subscribed via source and target branches