Blob Blame History Raw
diff -urN vim74_orig/src/option.c vim74/src/option.c
--- vim74_orig/src/option.c	2016-12-12 12:18:52.614342651 +0100
+++ vim74/src/option.c	2016-12-12 12:34:08.192983990 +0100
@@ -5663,6 +5663,21 @@
     return r;
 }
 
+ /*
+ * Return TRUE if "val" is a valid 'filetype' name.
+ * Also used for 'syntax' and 'keymap'.
+ */
+    static int
+valid_filetype(char_u *val)
+{
+    char_u *s;
+
+    for (s = val; *s != NUL; ++s)
+   if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
+       return FALSE;
+    return TRUE;
+}
+
 /*
  * Handle string options that need some action to perform when changed.
  * Returns NULL for success, or an error message for an error.
@@ -6054,8 +6069,11 @@
 #ifdef FEAT_KEYMAP
     else if (varp == &curbuf->b_p_keymap)
     {
-	/* load or unload key mapping tables */
-	errmsg = keymap_init();
+        if (!valid_filetype(*varp))
+            errmsg = e_invarg;
+        else
+            /* load or unload key mapping tables */
+            errmsg = keymap_init();	
 
 	if (errmsg == NULL)
 	{
@@ -7010,6 +7028,23 @@
     }
 #endif
 
+#ifdef FEAT_AUTOCMD
+    else if (gvarp == &p_ft)
+    {
+   if (!valid_filetype(*varp))
+       errmsg = e_invarg;
+    }
+#endif
+
+#ifdef FEAT_SYN_HL
+    else if (gvarp == &p_syn)
+    {
+   if (!valid_filetype(*varp))
+       errmsg = e_invarg;
+    }
+#endif
+
+
     /* Options that are a list of flags. */
     else
     {