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.

§63 ANNOYANCE-FILTER QUOTED-PRINTABLE MIME DECODER 59<br />

63. Some systems pad text lines with white space (ASCII blank or horizontal tab characters). This<br />

may result in a line encoded with a “soft line break” at the end appearing, when decoded, with white<br />

space between the supposedly-trailing equal sign and the end of line sequence. If white space follows<br />

an equal sign escape, we ignore it up to the beginning of an end of line sequence. Non-white space<br />

appearing before we sense the end of line is an error; these erroneous characters are ignored.<br />

〈 Ignore white space after soft line break 63 〉 ≡<br />

while (〈 Character is white space 62 〉) {<br />

ch1 = getNextChar ( );<br />

if (ch1 ≡ ’\n’) {<br />

continue;<br />

}<br />

if (¬〈 Character is white space 62 〉) {<br />

nDecodeErrors ++;<br />

}<br />

}<br />

ostringstream os ;<br />

os ≪ "Invalid␣character␣’" ≪ static cast〈char〉(ch1 ) ≪<br />

"’␣after␣soft␣line␣break␣in␣Quoted−Printable␣MIME␣part.";<br />

mf ⃗ reportParserDiagnostic(os .str ( ));<br />

ch1 = ’␣’; /∗ Fake a space and soldier on ∗/<br />

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

64. <strong>The</strong> hex to nybble method converts a hexadecimal digit in the sequence “0123456789ABCDEF” or<br />

the equivalent with lower case letters to its binary value. If an invalid hexadecimal digit is supplied, −1<br />

is returned.<br />

〈 Class implementations 11 〉 +≡<br />

int quotedPrintableMIMEdecoder ::hex to nybble (const int ch )<br />

{<br />

if ((ch ≥ ’0’) ∧ (ch ≤ (’0’ + 9))) {<br />

return ch − ’0’;<br />

}<br />

else if ((ch ≥ ’A’) ∧ (ch ≤ (’A’ + 5))) {<br />

return 10 + (ch − ’A’);<br />

}<br />

else if ((ch ≥ ’a’) ∧ (ch ≤ (’a’ + 5))) {<br />

return 10 + (ch − ’a’);<br />

}<br />

return −1;<br />

}

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

Saved successfully!

Ooh no, something went wrong!