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.

58 QUOTED-PRINTABLE MIME DECODER ANNOYANCE-FILTER §61<br />

61. Return the next character from the encoded input stream. Since end of line sequences have been<br />

stripped, we append our own new-line character to the end of each line. This indicates that in the<br />

absence of a soft line break (trailing equal sign), we should emit a line break to the output stream.<br />

〈 Class implementations 11 〉 +≡<br />

int quotedPrintableMIMEdecoder ::getNextChar (void)<br />

{<br />

while (true ) {<br />

if (atEndOfLine ) {<br />

atEndOfLine = false ;<br />

return ’\n’;<br />

}<br />

if (ip < inputLine .length ( )) {<br />

if (ip ≡ (inputLine .length ( ) − 1)) {<br />

atEndOfLine = true ;<br />

}<br />

return inputLine [ip ++];<br />

}<br />

if (¬getNextEncodedLine ( )) {<br />

break;<br />

}<br />

if (inputLine .length ( ) ≡ 0) {<br />

atEndOfLine = true ;<br />

}<br />

}<br />

return −1;<br />

}<br />

62. <strong>The</strong>re are lots of ways of defining “ASCII white space,” but RFC 1521 explicitly states that only<br />

ASCII space and horizontal tab characters are deemed white space for the purposes of Quoted-Printable<br />

encoding. However, we must also cope with POP3 messages where the lines are terminated with CR/LF,<br />

so we extend the definition to allow a carriage return before the line feed. This is easily accomplished<br />

by broadening the definition of white space to include carriage return.<br />

〈 Character is white space 62 〉 ≡<br />

((ch1 ≡ ’␣’) ∨ (ch1 ≡ ’\t’) ∨ (ch1 ≡ ’\r’))<br />

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

This code is used in section 63.

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

Saved successfully!

Ooh no, something went wrong!