On 13 Oct 2013 13:56, "Waqas Hussain" <[email protected]> wrote: > Would getting to write a MIME over XMPP spec be a suitable prize? But > wait, MIME has escape sequences (and also, what MIME exactly? there's > so much to choose from in there...). :) >
The basic structure of MIME, in particular multipart/* and message/rfc822, is such that you can take one MIME message and embed it in another - however there's no escaping used. The way it works instead is to use boundaries which are simply very unlikely to occur within the encapsulated part. The boundaries aren't tested by MIME engines, as far as I'm aware. So forwarding this message as an attachment will fully encapsulate it, one text-based language in another, without any escaping. You can also sling (unencoded) JSON, XML, and so on inside body parts without escaping, by a similar method. In fact, SQL and Lua, both using '--' sequences for comments, are the riskiest I suppose, but in practise you don't get a random string as a comment... > If you have a structured language with delimiters, and the content > inside those delimiters can contain the delimiters themselves, you > need escaping (as we discovered in the entity caps preimage issue). > Ways around that include length-encoding (which I'd say is very > non-friendly to humans), or EOF as end delimiter (which greatly limits > your structure). Or alternately you use delimiters which are both relatively long, unpredictable, and unlikely to occur even if they were. The general rule is that your data must not be confusable as your delimiter. Or to put it another way, the encapsulation must be unambiguous. Of course, in *this* case, we probably want to use XML's own escaping, and this particular subthread is Waqas and I waxing theoretical. :-) Dave.
