Skip to content

Commit 9507679

Browse files
committed
The patch to implement:
Validate properties specified for sorting and grouping in index views. Original patch from martin.v.loewis via: https://hg.python.org/tracker/roundup/rev/439bd3060df2 Applied by John Rouillard with some modification to properly identify if the bad property is a sort or grouping property. Tests added. has an issue with the current code base. Apparently sometime it can be entered without self.classname being defined. As a result the property lookup fails. So guard it by checking for self.classname in a couple of spots and if self.classname is not set just append the property and let the target action sort it out.
1 parent 711fa23 commit 9507679

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

roundup/cgi/templating.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,15 +2517,22 @@ def _parse_sort(self, var, name):
25172517
dirs.append(self.form.getfirst(dirkey))
25182518
if fields: # only try other special char if nothing found
25192519
break
2520-
cls = self.client.db.getclass(self.classname)
2520+
2521+
# sometimes requests come in without a class
2522+
# chances are they won't have any filter params,
2523+
# in that case anyway but...
2524+
if self.classname:
2525+
cls = self.client.db.getclass(self.classname)
25212526
for f, d in map(None, fields, dirs):
25222527
if f.startswith('-'):
25232528
dir, propname = '-', f[1:]
25242529
elif d:
25252530
dir, propname = '-', f
25262531
else:
25272532
dir, propname = '+', f
2528-
if cls.get_transitive_prop(propname) is None:
2533+
# if no classname, just append the propname unchecked.
2534+
# this may be valid for some actions that bypass classes.
2535+
if self.classname and cls.get_transitive_prop(propname) is None:
25292536
self.client.add_error_message("Unknown %s property %s"%(name, propname))
25302537
else:
25312538
var.append((dir, propname))

0 commit comments

Comments
 (0)