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.

§177 ANNOYANCE-FILTER TOKEN PARSER 151<br />

177. To avoid accidentally blundering into HTML comment discarding in non-HTML text, we look<br />

for start and end HTML tags and only activate HTML comment detection inside something which is<br />

plausibly HTML. Note that unclosed HTML tags and comments are automatically closed out when<br />

reset is called at the start of a new message from the mail folder.<br />

〈 Check for within HTML content 177 〉 ≡<br />

if (cl [clp] ≡ ’’ ∨ cl [clp + 5] ≡ ’␣’)) {<br />

string tag ;<br />

for (int i = 1; i < 5; i++) {<br />

tag += (islower (cl [clp + i])) ? toupper (cl [clp + i]) : cl [clp + i];<br />

}<br />

if (tag ≡ "HTML") {<br />

inHTML = true ;<br />

#ifdef HTML_COMMENT_DEBUG<br />

cout ≪ "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−␣In␣HTML:␣" ≪ cl ≪ endl ;<br />

#endif<br />

}<br />

}<br />

}<br />

if (cl [clp] ≡ ’’)) {<br />

string tag ;<br />

for (int i = 2; i < 6; i++) {<br />

tag += (islower (cl [clp + i])) ? toupper (cl [clp + i]) : cl [clp + i];<br />

}<br />

if (tag ≡ "HTML") {<br />

inHTML = false ;<br />

#ifdef HTML_COMMENT_DEBUG<br />

cout ≪ "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−␣Out␣of␣HTML:␣" ≪ cl ≪ endl ;<br />

#endif<br />

}<br />

}<br />

}<br />

This code is used in section 174.

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

Saved successfully!

Ooh no, something went wrong!