]> git.lyx.org Git - features.git/commitdiff
Fix dangerous parser use
authorGeorg Baum <baum@lyx.org>
Sat, 16 Feb 2013 13:16:42 +0000 (14:16 +0100)
committerGeorg Baum <baum@lyx.org>
Sat, 16 Feb 2013 16:48:42 +0000 (17:48 +0100)
Jean-Marc discovered a possible data loss caused by Parser::getChar().
This is now fixed, and Parser::getChar() is removed, since it is no longer
needed and easy to use it in the wrong way.

src/tex2lyx/Parser.cpp
src/tex2lyx/Parser.h
src/tex2lyx/text.cpp

index f5f5f46513f3df375f065f7df0d87eb168161648..547f424b9dab64f0e9ea78543c629178f81fab3f 100644 (file)
@@ -413,14 +413,6 @@ bool Parser::good()
 }
 
 
-char Parser::getChar()
-{
-       if (!good())
-               error("The input stream is not well...");
-       return get_token().character();
-}
-
-
 bool Parser::hasOpt()
 {
        // An optional argument can occur in any of the following forms:
index 5f8b1fa98c01bad2c1ecb3578a124aeb5c5a7790..3c55a7ebb093de8da33fe98983c6046f287334c6 100644 (file)
@@ -282,11 +282,6 @@ public:
        std::string verbatim_item();
        ///
        std::string verbatimOption();
-       /*!
-        * Returns the character of the current token and increments
-        * the token position.
-        */
-       char getChar();
        ///
        void error(std::string const & msg);
        /// The previous token.
index 07cb0775bdd4f2f8e75cd645f16a6f857739624d..2bf2c5aef4422e00497ce45345af83bb664f640f 100644 (file)
@@ -2105,10 +2105,10 @@ void parse_macro(Parser & p, ostream & os, Context & context)
 
                        // followed by number?
                        if (p.next_token().cat() == catOther) {
-                               char c = p.getChar();
-                               paramtext += c;
+                               string s = p.get_token().asInput();
+                               paramtext += s;
                                // number = current arity + 1?
-                               if (c == arity + '0' + 1)
+                               if (s.size() == 1 && s[0] == arity + '0' + 1)
                                        ++arity;
                                else
                                        simple = false;