Show
Ignore:
Timestamp:
2008-08-18 01:20:40 (3 months ago)
Author:
Rocco Rutte <pdmef@…>
Branch:
HEAD
Message:

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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • charset.c

    r5453 r5477  
    630630  FREE (_fc);           /* __FREE_CHECKED__ */ 
    631631} 
     632 
     633int mutt_check_charset (const char *s, int strict) 
     634{ 
     635  int i; 
     636  iconv_t cd; 
     637 
     638  if (mutt_is_utf8 (s)) 
     639    return 0; 
     640 
     641  if (!strict) 
     642    for (i = 0; PreferredMIMENames[i].key; i++) 
     643    { 
     644      if (ascii_strcasecmp (PreferredMIMENames[i].key, s) == 0 || 
     645          ascii_strcasecmp (PreferredMIMENames[i].pref, s) == 0) 
     646        return 0; 
     647    } 
     648 
     649  if ((cd = mutt_iconv_open (s, s, 0)) != (iconv_t)(-1)) 
     650  { 
     651    iconv_close (cd); 
     652    return 0; 
     653  } 
     654 
     655  return -1; 
     656}