Skip to content

Commit 576df4d

Browse files
author
Richard Jones
committed
handle :add: better in cgi form parsing [SF#663235]
1 parent c7c8d3d commit 576df4d

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ are given with the most recent entry first.
1212
(multipart/alternative, "fw" and content-type "name")
1313
- fire auditors and reactors in rdbms retire (thanks Sheila King)
1414
- better match for mailgw help "command" text
15+
- handle :add: better in cgi form parsing (sf bug 663235)
1516

1617

1718
2002-12-11 0.5.3

roundup/cgi/client.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.63 2002-12-15 23:55:33 richard Exp $
1+
# $Id: client.py,v 1.64 2003-01-08 04:33:56 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -1188,7 +1188,7 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
11881188

11891189
# does the property exist?
11901190
if not properties.has_key(propname):
1191-
if mlaction != 'set':
1191+
if mlaction == 'remove':
11921192
raise ValueError, 'You have submitted a remove action for'\
11931193
' the property "%s" which doesn\'t exist'%propname
11941194
continue
@@ -1198,8 +1198,18 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
11981198
# of MiniFieldStorages.
11991199
value = form[key]
12001200

1201-
# make sure non-multilinks only get one value
1202-
if not isinstance(proptype, hyperdb.Multilink):
1201+
# handle unpacking of the MiniFieldStorage / list form value
1202+
if isinstance(proptype, hyperdb.Multilink):
1203+
# multiple values are OK
1204+
if isinstance(value, type([])):
1205+
# it's a list of MiniFieldStorages
1206+
value = [i.value.strip() for i in value]
1207+
else:
1208+
# it's a MiniFieldStorage, but may be a comma-separated list
1209+
# of values
1210+
value = [i.strip() for i in value.value.split(',')]
1211+
else:
1212+
# multiple values are not OK
12031213
if isinstance(value, type([])):
12041214
raise ValueError, 'You have submitted more than one value'\
12051215
' for the %s property'%propname
@@ -1258,16 +1268,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
12581268
'for property "%(propname)s": %(message)s')%{
12591269
'propname': propname, 'message': message}
12601270
elif isinstance(proptype, hyperdb.Multilink):
1261-
if isinstance(value, type([])):
1262-
# it's a list of MiniFieldStorages
1263-
value = [i.value.strip() for i in value]
1264-
else:
1265-
# it's a MiniFieldStorage, but may be a comma-separated list
1266-
# of values
1267-
value = [i.strip() for i in value.value.split(',')]
1271+
# perform link class key value lookup if necessary
12681272
link = proptype.classname
12691273
l = []
1270-
for entry in map(str, value):
1274+
for entry in value:
12711275
if entry == '': continue
12721276
if not num_re.match(entry):
12731277
try:

0 commit comments

Comments
 (0)