util.FieldStorage __setitem__/__delitem__ might affect wrong field
------------------------------------------------------------------
Key: MODPYTHON-256
URL: https://issues.apache.org/jira/browse/MODPYTHON-256
Project: mod_python
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Any
Reporter: Anders Blomdell
When a FieldStorage has two (or more) Filed instances with the same value but
different names, the behaviour of programs like this is (more or less)
undefined:
fs = util.FieldStorage(req)
fs['id1'] = 'New value'
del fs['id2']
The reason for the undefinedness, is this code in __delitem__ (and the similar
in __setitem__):
table = self.list.table()
values = table[key]
for value in values:
self.list.remove(value)
What happens is that the self.list.remove(value) will remove the first field
with a matching value, regardless of that fields name. Here is an example from
real life:
form.clear()
form['id1'] = 'x'
form['id2'] = 'x'
form['id3'] = 'x'
# Form now contains {'id2': [Field('id2', 'x')],
# 'id3': [Field('id3', 'x')],
# 'id1': [Field('id1', 'x')]}
form['id2'] = 'y'
# Form now contains {'id2': [Field('id2', 'x'), Field('id2', 'y')],
# 'id3': [Field('id3', 'x')]}
# which is not what I would have expected
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.