-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
what(): Couldn't find Content-Type phrase (boundary) #332
Comments
See also: http://bugs.debian.org/730542 |
I'm not sure about this -- maybe @mclow can help? |
I have reduced test case. The following does not work: Content-Type: multipart/related; type=multipart/alternative; boundary="_NextPart_001_0037_D092C96B.3CE29AF1" --_NextPart_001_0037_D092C96B.3CE29AF1 R0lGODlh/ABLAMQAAP///wAAgAAA/wAAADMzmRERiEREoVVVqoiIw+7u9szM5SIikLu73d3d --_NextPart_001_0037_D092C96B.3CE29AF1-- However if I add " (quotes), then it works ok: Content-Type: multipart/related; type="multipart/alternative"; boundary="_NextPart_001_0037_D092C96B.3CE29AF1" --_NextPart_001_0037_D092C96B.3CE29AF1 R0lGODlh/ABLAMQAAP///wAAgAAA/wAAADMzmRERiEREoVVVqoiIw+7u9szM5SIikLu73d3d --_NextPart_001_0037_D092C96B.3CE29AF1-- |
So the parser requires two things: It should read as: and 2. the trailing line of a mime message should end with "\r\n" I am not sure why the python parser is relaxed about those. |
So, is this a problem with the Python parser, or the MIME code? |
MIME code. Quotes should not be required, but python handles both forms ref: |
I am not sure about the trailing \r\n. some guru would need to double check why MIME code needs trailing \r\n |
On Nov 26, 2013, at 4:15 AM, Mathieu Malaterre notifications@github.com wrote:
It’s because of the ‘/‘ in "application/dicom”. Slash is not allowed in a token in the Content-type header. See the paper Mathieu referenced:
|
The terminating CRLF is mandatory too: http://tools.ietf.org/html/rfc2046#section-5.1.1
So this is not a bug and the Python parser is too relaxed. |
Thanks all for the comments ! Closing then. |
I cannot parse the following mime file. Steps:
$ mkdir /tmp/d
$ cd /tmp/d
$ apt-get source cpp-netlib
$ cd cpp-netlib-0.10.1
$ g++ -o demo ./libs/mime/example/basic_parsing.cpp
$ ./demo.sh
$ ./libs/mime/test/mimeParse.py ./demo.mime
Data from: ./demo.mime
Content-Type: multipart/related
There are 1 headers
There are 1 sub parts
Content-Type: application/pdf
There are 1 headers
The body is 512 bytes long
0 0 0 0 0 ... 0 0 0 0 0
while:
$ ./demo ./demo.mime
terminate called after throwing an instance of 'std::runtime_error'
what(): Couldn't find Content-Type phrase (boundary)
[1] 1328 abort ./demo ./demo.mime
Where:
$ cat demo.sh
!/bin/sh
out=demo.mime
boundary="demo.bug.cpp-netlib"
content_type="Content-Type: multipart/related; type=application/pdf;
boundary=${boundary}"
echo -n "${content_type}\r\n\r\n" > $out
echo -n "--$boundary\r\n" >> $out
echo -n "Content-Type: application/pdf\r\n" >> $out
echo -n "\r\n" >> $out
head -c 1b /dev/zero >> $out
echo -n "\r\n" >> $out
echo -n "--$boundary--" >> $out
The text was updated successfully, but these errors were encountered: