Functions | |
void | stripquotes (char *s) |
Strip surrounding single or double quotes from a string. | |
void | extract_charset_from_meta (char *charset, char *meta_http_equiv, char *meta_content) |
Check to see if a META tag has overridden the declared MIME character set. | |
void | output_html (char *supplied_charset, int treat_as_wiki) |
Sanitize and enhance an HTML message for display. Also convert weird character sets to UTF-8 if necessary. |
void stripquotes | ( | char * | s | ) |
Strip surrounding single or double quotes from a string.
s | String to be stripped. |
Definition at line 20 of file html2html.c.
Referenced by output_html().
void extract_charset_from_meta | ( | char * | charset, | |
char * | meta_http_equiv, | |||
char * | meta_content | |||
) |
Check to see if a META tag has overridden the declared MIME character set.
charset | Character set name (left unchanged if we don't do anything) | |
meta_http_equiv | Content of the "http-equiv" portion of the META tag | |
meta_content | Content of the "content" portion of the META tag |
Definition at line 43 of file html2html.c.
References safestrncpy(), and striplt().
Referenced by output_html().
void output_html | ( | char * | supplied_charset, | |
int | treat_as_wiki | |||
) |
Sanitize and enhance an HTML message for display. Also convert weird character sets to UTF-8 if necessary.
supplied_charset | the input charset as declared in the MIME headers |
< Buffer of characters to be converted
< Buffer for converted characters
< Length of input buffer
< Length of output buffer
< Saved pointer to output buffer
flush
Do a first pass to isolate the message body
Advance to next tag
Look for META tags. Some messages (particularly in Asian locales) illegally declare a message's character set in the HTML instead of in the MIME headers. This is wrong but we have to work around it anyway.
Any of these tags cause everything up to and including the tag to be removed.
Any of these tags cause everything including and following the tag to be removed.
Convert foreign character sets to UTF-8 if necessary.
At this point, the message has been stripped down to only the content inside the <BODY></BODY> tags, and has been converted to UTF-8 if it was originally in a foreign character set. The text is also guaranteed to be null terminated now.
Now go through the message, parsing tags as necessary.
Change mailto: links to WebCit mail, by replacing the link with one that points back to our mail room. Due to the way we parse URL's, it'll even handle mailto: links that have "?subject=" in them.
Make external links open in a separate window
Turn anything that looks like a URL into a real link, as long as it's not inside a tag already
Find the end of the link
We need to know when we're inside a tag, so we don't turn things that look like URL's into links, when they're already links - or image sources.
uncomment these two lines to override conversion
memcpy(converted_msg, msg, content_length);
output_length = content_length;
Output our big pile of markup
A little trailing vertical whitespace...
Now give back the memory
Definition at line 85 of file html2html.c.
References client_write(), ctdl_iconv_open(), extract_charset_from_meta(), lprintf(), safestrncpy(), serv_getln(), striplt(), stripquotes(), and wprintf().
Referenced by display_rss(), and read_message().