]> git.lyx.org Git - features.git/commitdiff
Fix bug #8220: tex2lyx crashes on single-character commands
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 25 Jun 2012 09:04:56 +0000 (11:04 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 25 Jun 2012 09:04:56 +0000 (11:04 +0200)
Fix commit [aa9fed93/lyxgit]: it is never a good idea to call substr(4) on a string without checking its length. Moreover, it is even better in this case to check that the first letters are "text" as the reminder of the code assumes...

src/tex2lyx/text.cpp

index 50eee93a3d2291596ee63140d7afac665298232f..c28e4366e6f71461d18889b572ac253c42b79775 100644 (file)
@@ -3573,7 +3573,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                              context.font.language, lang);
                }
                
-               else if (is_known(t.cs().substr(4, string::npos), polyglossia_languages)) {
+               else if (prefixIs(t.cs(), "text") 
+                        && is_known(t.cs().substr(4), polyglossia_languages)) {
                        // scheme is \textLANGUAGE{text} where LANGUAGE is in polyglossia_languages[]
                        string lang;
                        // We have to output the whole command if it has an option