]> granicus.if.org Git - neomutt/commitdiff
add validator for wrap_headers
authorRichard Russon <rich@flatcap.org>
Thu, 24 Oct 2019 00:56:19 +0000 (01:56 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 27 Oct 2019 01:12:47 +0000 (01:12 +0000)
init.c
init.h

diff --git a/init.c b/init.c
index c902cd363e00b12f9ab7b7e97037de007c2b8aa8..aa13633a327d4f0c57758320e783f837c1c0d1cc 100644 (file)
--- 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 4b53a9ece870c9e2c7c3041568d90377945ff28a..f0653826843b978ae8052b601080608b8912f9ef 100644 (file)
--- 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