+2007-03-04 19:26 +0100 Alain Bench <veronatif@free.fr> (4dc1d87f4c25)
+
+ * doc/manual.xml.head, init.h: Doc fixes and updates concerning hooks
+
+ - Add reply-hooks and send2-hooks in lists they miss.
+ - Fix that they all take full patterns, not only regexps.
+ - Note interaction with $default_hook.
+ - Enumerate them in execution order/increasing priority.
+ - Add iconv-hook, remove a duplicate charset-hook.
+
+2007-03-06 15:45 -0800 Brendan Cully <brendan@kublai.com> (607688bd77b1)
+
+ * ChangeLog, hg-commit: Add check_sec.sh call
+
2007-03-06 15:43 -0800 Brendan Cully <brendan@kublai.com> (52c24a8a42a8)
* hg-commit: Make hg commit less clever
/*
- * Like iconv_open, but canonicalises the charsets
+ * Like iconv_open, but canonicalises the charsets, applies
+ * charset-hooks, recanonicalises, and finally applies iconv-hooks.
+ * Parameter flags=0 skips charset-hooks, while M_ICONV_HOOK_FROM
+ * applies them to fromcode.
*/
iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags)
char *tmp;
iconv_t cd;
-
+
+ /* transform to MIME preferred charset names */
mutt_canonical_charset (tocode1, sizeof (tocode1), tocode);
#ifdef M_ICONV_HOOK_TO
#endif
mutt_canonical_charset (fromcode1, sizeof (fromcode1), fromcode);
+
+ /* maybe apply charset-hooks and recanonicalise fromcode,
+ * but only when caller asked us to sanitize a potentialy wrong
+ * charset name incoming from the wild exterior. */
if ((flags & M_ICONV_HOOK_FROM) && (tmp = mutt_charset_hook (fromcode1)))
mutt_canonical_charset (fromcode1, sizeof (fromcode1), tmp);
- if ((cd = iconv_open (tocode1, fromcode1)) != (iconv_t) -1)
+ /* always apply iconv-hooks to suit system's iconv tastes */
+ tocode2 = mutt_iconv_hook (tocode1);
+ tocode2 = (tocode2) ? tocode2 : tocode1;
+ fromcode2 = mutt_iconv_hook (fromcode1);
+ fromcode2 = (fromcode2) ? fromcode2 : fromcode1;
+
+ /* call system iconv with names it appreciates */
+ if ((cd = iconv_open (tocode2, fromcode2)) != (iconv_t) -1)
return cd;
- if ((tocode2 = mutt_iconv_hook (tocode1)) && (fromcode2 = mutt_iconv_hook (fromcode1)))
- return iconv_open (tocode2, fromcode2);
return (iconv_t) -1;
}
memset (&pattern, 0, sizeof (pattern));
pattern.data = safe_strdup (path);
}
- else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
+ else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
&& (!WithCrypto || !(data & M_CRYPTHOOK))
)
{
char tmp[HUGE_STRING];
+ /* At this stage remain only message-hooks, reply-hooks, send-hooks,
+ * send2-hooks, save-hooks, and fcc-hooks: All those allowing full
+ * patterns. If given a simple regexp, we expand $default_hook.
+ */
strfcpy (tmp, pattern.data, sizeof (tmp));
mutt_check_simple (tmp, sizeof (tmp), DefaultHook);
FREE (&pattern.data);
}
else
{
+ /* Hooks not allowing full patterns: Check syntax of regexp */
rx = safe_malloc (sizeof (regex_t));
#ifdef M_CRYPTHOOK
- if ((rc = REGCOMP (rx, NONULL(pattern.data), ((data & (M_CRYPTHOOK|M_CHARSETHOOK)) ? REG_ICASE : 0))) != 0)
+ if ((rc = REGCOMP (rx, NONULL(pattern.data), ((data & (M_CRYPTHOOK|M_CHARSETHOOK|M_ICONVHOOK)) ? REG_ICASE : 0))) != 0)
#else
if ((rc = REGCOMP (rx, NONULL(pattern.data), (data & (M_CHARSETHOOK|M_ICONVHOOK)) ? REG_ICASE : 0)) != 0)
#endif /* M_CRYPTHOOK */
|| !ascii_strcasecmp(buffer, "cp932") || !ascii_strcasecmp(buffer, "eucJP-ms"))
{
charset_is_ja = 1;
- charset_to_utf8 = iconv_open ("UTF-8", charset);
- charset_from_utf8 = iconv_open (charset, "UTF-8");
+
+ /* Note flags=0 to skip charset-hooks: User masters the $charset
+ * name, and we are sure of our "UTF-8" constant. So there is no
+ * possibility of wrong name that we would want to try to correct
+ * with a charset-hook. Or rather: If $charset was wrong, we would
+ * want to try to correct... $charset directly.
+ */
+ charset_to_utf8 = mutt_iconv_open ("UTF-8", charset, 0);
+ charset_from_utf8 = mutt_iconv_open (charset, "UTF-8", 0);
}
#endif