[issue27308] Inconsistency in cgi.FieldStorage() causes unicode/byte TypeError.

2016-06-13 Thread Marcel Hellkamp

Marcel Hellkamp added the comment:

Looks like this is a duplicate to #24764 and already fixed. Sorry for the noise.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27308>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27308] Inconsistency in cgi.FieldStorage() causes unicode/byte TypeError.

2016-06-13 Thread Marcel Hellkamp

Marcel Hellkamp added the comment:

This should fix the issue.

--
keywords: +patch
Added file: http://bugs.python.org/file43378/foo.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27308>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27308] Inconsistency in cgi.FieldStorage() causes unicode/byte TypeError.

2016-06-13 Thread Marcel Hellkamp

Changes by Marcel Hellkamp <m...@gsites.de>:


--
title: Inconsistency in cgi.FieldStorage() causes unicode/byte issue. -> 
Inconsistency in cgi.FieldStorage() causes unicode/byte TypeError.

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27308>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27308] Inconsistency in cgi.FieldStorage() causes unicode/byte issue.

2016-06-13 Thread Marcel Hellkamp

New submission from Marcel Hellkamp:

Discovered here: https://github.com/bottlepy/bottle/issues/856

If a multipart section has a "Content-Length" header, but no "filename" 
attribute in the "Content-Disposition" header, cgi.FieldStorage tries to write 
binary data to a temporary file opened in text-mode.

The problem here is that cgi.FieldStorage tries to decide if something is a 
binary file-upload or a unicode form-field, but it does so based on two 
different headers in two different places. If the headers contradict each other 
(form-fields usually don't have a Content-Length, file-uploads usually have a 
filename), parsing breaks with a TypeError.

Unfortunately, there are some HTTP client libraries out there that trigger this 
bug.



Here is what happens:

A "Content-Length" header causes `cgi.FieldStorage.length` to be is set (which 
is fine).
https://hg.python.org/cpython/file/3.4/Lib/cgi.py#l550

If `length` has a value, `read_binary()` is used instead of `read_lines()` 
(which is questionable).
https://hg.python.org/cpython/file/3.4/Lib/cgi.py#l733

`read_binary()` calls `make_file()` which creates the buffer file in text mode 
if it does not find a `filename` attribute in the "Content-Disposition" Header 
(which is somewhat okay).
https://hg.python.org/cpython/file/3.4/Lib/cgi.py#l515
https://hg.python.org/cpython/file/3.4/Lib/cgi.py#l893

The bug is triggered if the last two steps disagree on the bytes vs. text 
question.

--
components: Library (Lib)
messages: 268460
nosy: Marcel Hellkamp
priority: normal
severity: normal
status: open
title: Inconsistency in cgi.FieldStorage() causes unicode/byte issue.
type: crash
versions: Python 3.4, Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27308>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23122] python@93442 breaks build if system Python is 2.6

2014-12-27 Thread Marcel Hellkamp

New submission from Marcel Hellkamp:

On CentOS 6.6 the system Python is 2.6. The use to set literals in 
Parser/adsl.py breaks the build process on these systems. The ./configure 
should ensure that a compatible version of python is available.

--
components: Build
messages: 233134
nosy: Marcel.Hellkamp
priority: normal
severity: normal
status: open
title: python@93442 breaks build if system Python is 2.6
type: compile error
versions: Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23122
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23122] python@93442 breaks build if system Python is 2.6

2014-12-27 Thread Marcel Hellkamp

Marcel Hellkamp added the comment:

make touch solved the problem. A clear case of RTFM :) Sorry for the noise.

--
resolution:  - not a bug
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23122
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18394] cgi.FieldStorage triggers ResourceWarning sometimes

2014-01-12 Thread Marcel Hellkamp

Marcel Hellkamp added the comment:

This change breaks existing applications.

The cgi.FieldStorage.file attribute is public and mentioned in the 
documentation. It even states You can then read the data at leisure from the 
file attribute.

Consider this example::

form = cgi.FieldStorage()
fileitem = form.getfirst(userfile)
if fileitem and fileitem.file:
executor.submit(store_file, fileitem.file, fileitem.filename)

This code is no longer safe. The garbage collector might close the file handle 
while it is still referenced and accessed from the worker thread.

Another example is the bottle web framework. It uses cgi.FieldStorage for 
parsing only, extracts the valuable information and stores the result in its 
own data structures. The cgi.FieldStorage instance is lost. Python 3.4 breaks 
every single bottle application that works with file uploads.

How about implementing the context manager protocol for cgi.FieldStorage to 
resolve this issue?

--
nosy: +Marcel.Hellkamp

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18394
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9019] wsgiref.headers.Header() does not update headers list it was created with.

2010-06-17 Thread Marcel Hellkamp

New submission from Marcel Hellkamp defn...@gmail.com:

The current (3.x) implementation of wsgiref.headers.Headers() does not match 
the documentation.

Documented behaviour:
Any changes made to the new Headers object will directly update the headers 
list it was created with. (/Doc/library/wsgiref.rst)

Actual behaviour:
The initial headers list is not updated.

The error was introduced with revision 68205. See 
http://svn.python.org/view/python/branches/py3k/Lib/wsgiref/headers.py?view=diffr1=68204r2=68205

Revision 68204::
 from wsgiref.headers import Headers
 l = []
 h = Headers(l)
 h.add_header('Test','Test')
 l
[('Test', 'Test')]

Revision 68205::
 from wsgiref.headers import Headers
 l = []
 h = Headers(l)
 h.add_header('Test','Test')
 l
[]

--
components: Library (Lib)
messages: 108042
nosy: Marcel.Hellkamp
priority: normal
severity: normal
status: open
title: wsgiref.headers.Header() does not update headers list it was created 
with.
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9019
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com