mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
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.
This commit is contained in:
parent
00f8bfcae5
commit
1b675d3a62
11
src/Text.cpp
11
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();
|
||||
|
Loading…
Reference in New Issue
Block a user