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.
#include "Cursor.h"
#include "CutAndPaste.h"
#include "DispatchResult.h"
+#include "Encoding.h"
#include "ErrorList.h"
#include "FuncRequest.h"
#include "factory.h"
}
}
+ // 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();