Skip to content
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

problematic implementation of getMessageBody #22

Open
GoogleCodeExporter opened this issue May 22, 2015 · 1 comment
Open

problematic implementation of getMessageBody #22

GoogleCodeExporter opened this issue May 22, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

posit: it's probably safe to assume that mailparser will always return the 
parts list in order. (1, 1.1, 1.2...)

given that, getMessageBody returns the body of the -last- matching part with 
the requested content-type.

this is probably not what most people expect.

even worse, mailparser seems to take a very simple single-part test email i 
have, but in addition to the 1.1, text/plain, it has added a 1.2, with zero 
length body, and also text/plain for no obvious reason (possible bug in 
mailparser? but i'm not an expert on the RFC)

for my own testcase, my single part text-only email, i would have expected 
getMessageBody to return the body.  instead, it returns an empty string because 
part 1.2 is also text/plain, and of length zero.

two possible fixes:

1. have getMessageBody return the first matching part

or

2. ignore any zero length body in the foreach.

for my own use, i did both.

and yes, it is a somewhat fuzzy request, asking for the "message body" from a 
multipart message, but these two changes might help.

Original issue reported on code.google.com by [email protected] on 9 Mar 2011 at 9:36

@GoogleCodeExporter
Copy link
Author

 In the case where a user sends an email like this:

  Hey, look at this funny picture:

  [image]

  Isn't that duck adorable?

...there will be two text/plain parts which both (arguably, at least) contain 
parts of the message body. I dealt with this by changing getMessageBody() to 
return the concatenation of all matching parts, although I'm not sure if this 
is a reasonable solution. I'm happy to provide a patch if it seems reasonable, 
it basically boils down to changing "$body =" to "$body .=" in getMessageBody().

Original comment by [email protected] on 13 Jun 2011 at 5:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant