Skip to content

Commit 1fecc6a

Browse files
committed
REST: Bug-fixes
Don't lowercase the path, otherwise url-parameters are lowercased, too. Fix re-used variable in new item lookup.
1 parent f80c62d commit 1fecc6a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

roundup/rest.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ def decorator(func):
284284

285285
@classmethod
286286
def execute(cls, instance, path, method, input):
287-
# format the input
288-
path = path.strip('/').lower()
287+
# format the input, note that we may not lowercase the path
288+
# here, URL parameters are case-sensitive
289+
path = path.strip('/')
289290
if path == 'rest':
290291
# allow handler to be called for /rest/
291292
path = 'rest/'
@@ -623,7 +624,7 @@ def get_element(self, class_name, item_id, input):
623624
uid = self.db.getuid()
624625
# If it's not numeric it is a key
625626
if item_id.isdigit():
626-
id = item_id
627+
itemid = item_id
627628
else:
628629
keyprop = class_obj.getkey()
629630
try:
@@ -640,16 +641,16 @@ def get_element(self, class_name, item_id, input):
640641
'Permission to view %s%s.%s denied'
641642
% (class_name, item_id, keyprop)
642643
)
643-
id = class_obj.lookup(v)
644+
itemid = class_obj.lookup(v)
644645
if not self.db.security.hasPermission(
645-
'View', uid, class_name, itemid=id
646+
'View', uid, class_name, itemid=itemid
646647
):
647648
raise Unauthorised(
648-
'Permission to view %s%s denied' % (class_name, id)
649+
'Permission to view %s%s denied' % (class_name, itemid)
649650
)
650651

651-
node = class_obj.getnode(id)
652-
etag = calculate_etag(node, class_name, id)
652+
node = class_obj.getnode(itemid)
653+
etag = calculate_etag(node, class_name, itemid)
653654
props = None
654655
protected=False
655656
verbose=1
@@ -666,15 +667,14 @@ def get_element(self, class_name, item_id, input):
666667
verbose = int (value)
667668

668669
result = {}
669-
uid = self.db.getuid()
670670
if props is None:
671671
props = class_obj.getprops(protected=protected)
672672

673673
try:
674674
for pn in sorted(props):
675675
prop = props[pn]
676676
if not self.db.security.hasPermission(
677-
'View', uid, class_name, pn, id
677+
'View', uid, class_name, pn, itemid
678678
):
679679
continue
680680
v = getattr(node, pn)
@@ -713,7 +713,7 @@ def get_element(self, class_name, item_id, input):
713713
except KeyError as msg:
714714
raise UsageError("%s field not valid" % msg)
715715
result = {
716-
'id': id,
716+
'id': itemid,
717717
'type': class_name,
718718
'link': '%s/%s/%s' % (self.data_path, class_name, item_id),
719719
'attributes': dict(result),

0 commit comments

Comments
 (0)