12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

130 MAIL FOLDER ANNOYANCE-FILTER §150<br />

150. A multi-part message in MIME format will contain a declaration in the header which identifies<br />

the body as being in that format and provides a part separator sentinel which appears before each<br />

subsequent part. We test for the MIME declaration and save the part boundary sentinel for later use.<br />

〈 Process multipart MIME header declaration 150 〉 ≡<br />

string ::size type p, p1 ;<br />

string arg ;<br />

if (inHeader ∧ compareHeaderField (s, "content−type", arg )) {<br />

string sc = s;<br />

}<br />

stringCanonicalise (sc);<br />

if ((p = sc.find ("multipart/", 13)) ≠ string ::npos ) {<br />

if ((p = sc.find ("boundary=", p + 10)) ≠ string ::npos ) {<br />

if (s[p + 9] ≡ ’\"’) {<br />

p1 = sc.find ("\"", p + 10);<br />

p += 10;<br />

}<br />

else {<br />

p += 9;<br />

p1 = sc.length ( ) − p;<br />

}<br />

multiPart = true ;<br />

partBoundary = s.substr (p, (p1 − p));<br />

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

ostringstream os ;<br />

}<br />

}<br />

}<br />

os ≪ "Multi−part␣boundary:␣\"" ≪ partBoundary ≪ "\"";<br />

reportParserDiagnostic(os );<br />

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

This code is used in section 141.<br />

151. If we’re in the body of a MIME multi-part message, we must test each line against the<br />

partBoundary sentinel declared in the “Content−type:” header statement. If the line is a part boundary,<br />

we then must parse the part header which follows.<br />

〈 Check for MIME part sentinel 151 〉 ≡<br />

if (multiPart ∧ (¬inHeader ) ∧ (partBoundary ≠ "") ∧ (s.substr (0, 2) ≡ "−−") ∧ (s.substr (2,<br />

partBoundary .length ( )) ≡ partBoundary ) ∧ (s.substr (partBoundary .length ( ) + 2) ≠ "−−")) {<br />

inPartHeader = true ;<br />

mimeContentType = mimeContentTypeCharset = mimeContentTypeBoundary =<br />

mimeContentTransferEncoding = "";<br />

}<br />

This code is used in section 130.

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

Saved successfully!

Ooh no, something went wrong!