From: Richard Russon Date: Thu, 24 Oct 2019 00:56:19 +0000 (+0100) Subject: add validator for wrap_headers X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=972b38927d52de8a989af6418a5997ee4e8d2931;p=neomutt add validator for wrap_headers --- diff --git a/init.c b/init.c index c902cd363..aa13633a3 100644 --- a/init.c +++ b/init.c @@ -3907,3 +3907,16 @@ int reply_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, cdef->name); return CSR_ERR_INVALID; } + +/** + * wrapheaders_validator - Validate the "wrap_headers" config variable - Implements ::cs_validator() + */ +int wrapheaders_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, + intptr_t value, struct Buffer *err) +{ + if ((value >= 78) && (value <= 998)) // Recommendation from RFC5233 + return CSR_SUCCESS; + + mutt_buffer_printf(err, _("Option %s must between 78 and 998 inclusive"), cdef->name); + return CSR_ERR_INVALID; +} diff --git a/init.h b/init.h index 4b53a9ece..f06538268 100644 --- a/init.h +++ b/init.h @@ -119,11 +119,12 @@ enum MuttSetCommand /* This option is deprecated */ bool C_IgnoreLinearWhiteSpace = false; -int charset_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); -int hcache_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); -int multipart_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); -int pager_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); -int reply_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); +int charset_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); +int hcache_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); +int multipart_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); +int pager_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); +int reply_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); +int wrapheaders_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err); struct ConfigDef MuttVars[] = { /*++*/ @@ -4849,7 +4850,7 @@ struct ConfigDef MuttVars[] = { ** .pp ** Also see $$reflow_wrap. */ - { "wrap_headers", DT_NUMBER|DT_NOT_NEGATIVE|R_PAGER, &C_WrapHeaders, 78 }, + { "wrap_headers", DT_NUMBER|DT_NOT_NEGATIVE|R_PAGER, &C_WrapHeaders, 78, 0, wrapheaders_validator }, /* ** .pp ** This option specifies the number of characters to use for wrapping