diff options
author | Rocco Rutte <pdmef@gmx.net> | 2008-08-18 10:20:40 +0200 |
---|---|---|
committer | Rocco Rutte <pdmef@gmx.net> | 2008-08-18 10:20:40 +0200 |
commit | c69de21086cd552d88be90cd6e626129168efaa3 (patch) | |
tree | 43822820193d08052fab3e86235c60a6e714edf1 /charset.c | |
parent | 06ba5e75095170b9d640b704841f905edf463399 (diff) |
Validate charset names for all charset options.
Validation is either done against mutt's table of IANA assigned names or local iconv
implementation (based on the assumption that iconv_open(charset,charset) fails if charset
is unknown to the implementation). Closes #1668.
Diffstat (limited to 'charset.c')
-rw-r--r-- | charset.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -629,3 +629,28 @@ void fgetconv_close (FGETCONV **_fc) iconv_close (fc->cd); FREE (_fc); /* __FREE_CHECKED__ */ } + +int mutt_check_charset (const char *s, int strict) +{ + int i; + iconv_t cd; + + if (mutt_is_utf8 (s)) + return 0; + + if (!strict) + for (i = 0; PreferredMIMENames[i].key; i++) + { + if (ascii_strcasecmp (PreferredMIMENames[i].key, s) == 0 || + ascii_strcasecmp (PreferredMIMENames[i].pref, s) == 0) + return 0; + } + + if ((cd = mutt_iconv_open (s, s, 0)) != (iconv_t)(-1)) + { + iconv_close (cd); + return 0; + } + + return -1; +} |