chiark / gitweb /
cgi.py: Don't crash if we have three values for a parameter.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 23 May 2014 17:22:44 +0000 (18:22 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 24 May 2014 21:58:29 +0000 (22:58 +0100)
The first time we see a parameter, we add it to `PARAMDICT'.  The second
time, we remove it again because it's multivalued.  The third time, we
try to remove it again, and that fails because it's already gone.

cgi.py

diff --git a/cgi.py b/cgi.py
index cfa26f7725ec55faf0e13849ac5b0ef3fd2ce04e..69b90386b36ae99638697643e737cc98eb8e11b6 100644 (file)
--- a/cgi.py
+++ b/cgi.py
@@ -419,7 +419,8 @@ def cgiparse():
     else:
       PARAM.append((k, v))
       if k in seen:
     else:
       PARAM.append((k, v))
       if k in seen:
-        del PARAMDICT[k]
+        try: del PARAMDICT[k]
+        except KeyError: pass
       else:
         PARAMDICT[k] = v
         seen.add(k)
       else:
         PARAMDICT[k] = v
         seen.add(k)