From 1b675d3a62c6bf14fe3a4b3933b913a28fde9a4a Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 9 Mar 2014 10:30:20 +0100 Subject: [PATCH] Prevent the most important case of bug #9012 Currently you can easily create an uncompilable document if you insert non-ASCII characters in a pass-through paragraph (e.g. ERT inset or verbatim style). This commit prevents entering these characters directly, but of course they can still be inserted via tricks, e.g. changing a standard paragraph to verbatim. A complete fix would handle this case as well, and also change the fixed latin1 encoding of latex_language to a dynamic one, so that a verbatim paragraph can contain any character that is encodable in the encoding of its environment. --- src/Text.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Text.cpp b/src/Text.cpp index 70805dfe84..c4cac8892e 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -30,6 +30,7 @@ #include "Cursor.h" #include "CutAndPaste.h" #include "DispatchResult.h" +#include "Encoding.h" #include "ErrorList.h" #include "FuncRequest.h" #include "factory.h" @@ -1004,6 +1005,16 @@ void Text::insertChar(Cursor & cur, char_type c) } } + // Prevent to insert uncodable characters in verbatim and ERT + // (workaround for bug 9012) + if (cur.paragraph().isPassThru() && cur.current_font.language()) { + Encoding const * e = cur.current_font.language()->encoding(); + if (!e->encodable(c)) { + cur.message(_("Character is uncodable in verbatim paragraphs.")); + return; + } + } + par.insertChar(cur.pos(), c, cur.current_font, cur.buffer()->params().trackChanges); cur.checkBufferStructure(); -- 2.39.5