From d0187055d8088d40205b7f9487a8ab5c5f66ecf5 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 4 Feb 2020 02:13:03 -0500 Subject: [PATCH] init: Print a warning when non-ASCII encoding is used in a modeline. --- options.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/options.c b/options.c index bfc3af56..7ff35720 100644 --- a/options.c +++ b/options.c @@ -122,8 +122,15 @@ options_init_config(char *execpath, char *configpath, int *init_flags, string_ar /* Simple state machine to translate both modeline and shebang into argv */ for (int i = 0; (c = file_buf[i++]) != '\0';) { /* Be very permissive, skip the unknown, UTF is not allowed */ - if ((c > 126 || c < 32) && c != 10 && c != 13 && c != 9) + if ((c > 126 || c < 32) && c != 10 && c != 13 && c != 9) { + static bool once = true; + /* Print a warning once */ + if (once) { + fprintf(stderr, "WARNING: modelines must use ASCII\n"); + once = false; + } continue; + } switch (state) { case MODELINE_STATE_INIT: