~milner/cloud-init/protect-from-bad-part-handlers

Viewing all changes in revision 497.

fix issue with part-handlers and base64 encoding (LP: #874342)

Previously,
 * if content came into cloud-init for processing came in via a multipart
   mime file, and was already base64 encoded, it would get base64 encoded
   again before being handed to a part-handler.
 * if it came in via a '#include'd file then it would not be encoded at
   all.

This drops the internal 'parts' array, that was just converted to and then
from.  Instead, we keep MIME format throughout and keep headers along
the way.

That means that a message that comes in with 'Content-Transfer-Encoding'
set to 'base64' will be decoded before being handed to a part-handler.

It also reduces the chance of failure due to content appearing to be an
actual email.  Previously if content contained colon separated fields, it
might be read as headers (email.message_from_string(open("/etc/passwd","r"))
would come back as all headers, no payload)

The weak point right now is that '#include'd data cannot have mime types
associated with it (unless it is a mime formatted content).  I had hoped
to read user headers and possibly set 'Content-Type' from that.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: