12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

§160 ANNOYANCE-FILTER MAIL FOLDER 135<br />

160. If the contents appear to be in a character set we understand, we still aren’t home free—the part<br />

may be encoded in a manner for which we lack a decoder. Analyse the Content−Transfer−Encoding<br />

specification and select the appropriate decoder. If we lack a decoder, we must regretfully consign the<br />

part to the sink decoder.<br />

If we end up accreting any additional decoders, this should probably be re-written to look up the<br />

decoder in a map〈string, MIMEdecoder ∗〉 and use common code for every decoder.<br />

〈 Verify Content-Transfer-Encoding and activate decoder if necessary 160 〉 ≡<br />

if (¬gibberish ) {<br />

if ((mimeContentTransferEncoding .length ( ) ≡ 0) ∨ (mimeContentTransferEncoding .substr (0,<br />

4) ≡ "7bit") ∨ (mimeContentTransferEncoding .substr (0,<br />

4) ≡ "8bit") ∨ (mimeContentTransferEncoding ≡ "ascii")) {<br />

imd .set(is , this, partBoundary , tlist ); /∗ Identity ∗/<br />

mdp = &imd ;<br />

}<br />

else if (mimeContentTransferEncoding ≡ "base64") {<br />

bmd .set(is , this, partBoundary , tlist ); /∗ Base64 ∗/<br />

mdp = &bmd ;<br />

}<br />

else if (mimeContentTransferEncoding ≡ "quoted−printable") {<br />

qmd .set(is , this, partBoundary , tlist ); /∗ Quoted−Printable ∗/<br />

mdp = &qmd ;<br />

}<br />

else {<br />

gibberish = true ;<br />

smd .set(is , this, partBoundary , tlist ); /∗ Sink ∗/<br />

mdp = &smd ;<br />

}<br />

assert(mdp ≠ Λ);<br />

if (Annotate (’d’)) {<br />

ostringstream os ;<br />

}<br />

os ≪ (gibberish ? "Rejecting" : "Accepting") ≪<br />

"␣part␣in␣Content−Transfer−Encoding:␣" ≪ mimeContentTransferEncoding ≪<br />

"␣␣(" ≪ mimeContentTypeCharset ≪ "␣" ≪ mimeContentType ≪ ")";<br />

reportParserDiagnostic(os );<br />

}<br />

if (dlist ) {<br />

dlist ⃗ push back (Xfile + "−Decoder:␣" + mdp ⃗ name ( ));<br />

}<br />

if (Annotate (’d’)) {<br />

ostringstream os ;<br />

}<br />

os ≪ "Activating␣MIME␣" ≪ mdp ⃗ name ( ) ≪ "␣decoder␣with␣sentinel:␣" ≪ partBoundary ;<br />

reportParserDiagnostic(os );<br />

This code is cited in section 256.<br />

This code is used in section 158.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!