[LyX/master] Prevent the most important case of bug #9012
commit 1b675d3a62c6bf14fe3a4b3933b913a28fde9a4a Author: Georg Baum b...@lyx.org Date: Sun Mar 9 10:30:20 2014 +0100 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. diff --git a/src/Text.cpp b/src/Text.cpp index 70805df..c4cac88 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();
[LyX/master] Prevent the most important case of bug #9012
commit 1b675d3a62c6bf14fe3a4b3933b913a28fde9a4a Author: Georg BaumDate: Sun Mar 9 10:30:20 2014 +0100 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. diff --git a/src/Text.cpp b/src/Text.cpp index 70805df..c4cac88 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();