mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Now a from submitted via POST that also has a query string
will contain both FieldStorage and MiniFieldStorage items. Fixes #1817.
This commit is contained in:
		
							parent
							
								
									2da91c375b
								
							
						
					
					
						commit
						a6a4d50efe
					
				
					 4 changed files with 103 additions and 0 deletions
				
			
		
							
								
								
									
										11
									
								
								Lib/cgi.py
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								Lib/cgi.py
									
										
									
									
									
								
							|  | @ -456,6 +456,7 @@ def __init__(self, fp=None, headers=None, outerboundary="", | |||
|         self.strict_parsing = strict_parsing | ||||
|         if 'REQUEST_METHOD' in environ: | ||||
|             method = environ['REQUEST_METHOD'].upper() | ||||
|         self.qs_on_post = None | ||||
|         if method == 'GET' or method == 'HEAD': | ||||
|             if 'QUERY_STRING' in environ: | ||||
|                 qs = environ['QUERY_STRING'] | ||||
|  | @ -474,6 +475,8 @@ def __init__(self, fp=None, headers=None, outerboundary="", | |||
|                 headers['content-type'] = "application/x-www-form-urlencoded" | ||||
|             if 'CONTENT_TYPE' in environ: | ||||
|                 headers['content-type'] = environ['CONTENT_TYPE'] | ||||
|             if 'QUERY_STRING' in environ: | ||||
|                 self.qs_on_post = environ['QUERY_STRING'] | ||||
|             if 'CONTENT_LENGTH' in environ: | ||||
|                 headers['content-length'] = environ['CONTENT_LENGTH'] | ||||
|         self.fp = fp or sys.stdin | ||||
|  | @ -631,6 +634,8 @@ def __nonzero__(self): | |||
|     def read_urlencoded(self): | ||||
|         """Internal: read data in query string format.""" | ||||
|         qs = self.fp.read(self.length) | ||||
|         if self.qs_on_post: | ||||
|             qs += '&' + self.qs_on_post | ||||
|         self.list = list = [] | ||||
|         for key, value in parse_qsl(qs, self.keep_blank_values, | ||||
|                                     self.strict_parsing): | ||||
|  | @ -645,6 +650,12 @@ def read_multi(self, environ, keep_blank_values, strict_parsing): | |||
|         if not valid_boundary(ib): | ||||
|             raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) | ||||
|         self.list = [] | ||||
|         if self.qs_on_post: | ||||
|             for key, value in parse_qsl(self.qs_on_post, self.keep_blank_values, | ||||
|                                         self.strict_parsing): | ||||
|                 self.list.append(MiniFieldStorage(key, value)) | ||||
|             FieldStorageClass = None | ||||
| 
 | ||||
|         klass = self.FieldStorageClass or self.__class__ | ||||
|         part = klass(self.fp, {}, ib, | ||||
|                      environ, keep_blank_values, strict_parsing) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Facundo Batista
						Facundo Batista