[PATCH]: Fix bug in RTF importer

From: Gianni Tedesco (gianni@scaramanga.co.uk)
Date: Tue Jun 24 2003 - 17:08:16 EDT

  • Next message: Dom Lachowicz: "Re: [PATCH]: Fix bug in RTF importer"

    Patch kinda says it all.

    Fixes a bug whereby an RTF file with a valid fonttbl data could be
    barfed on. The problem is basically that whitespace isn't being skipped
    in the fonttbl parser so if you have an RTF generated for example by
    latex2rtf which looks like this:
     
    {\fonttbl
     {\f13\fnil\fcharset0 Courier;}
    }
     
    instead of like this:
    {\fonttbl
    {\f13\fnil\fcharset0 Courier;}
    }
     
    then the import fails. The fix works by skipping past any characters
    until a { or } is reached.

    Thanks!

    -- 
    // Gianni Tedesco (gianni at scaramanga dot co dot uk)
    lynx --source www.scaramanga.co.uk/gianni-at-ecsc.asc | gpg --import
    8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
    

    Fixes a bug whereby an RTF file with a valid fonttbl data could be barfed on.
    The problem is basically that whitespace isn't being skipped in the fonttbl
    parser so if you have an RTF generated for example by latex2rtf which looks
    like this:

    {\fonttbl
     {\f13\fnil\fcharset0 Courier;}
    }

    instead of like this:
    {\fonttbl
    {\f13\fnil\fcharset0 Courier;}
    }

    then the import fails.

    --- abiword-1.99.1/abi/src/wp/impexp/xp/ie_imp_RTF.cpp 2003-06-08 09:43:55.000000000 +0100
    +++ abiword-1.99.1-dev/abi/src/wp/impexp/xp/ie_imp_RTF.cpp 2003-06-24 21:44:33.000000000 +0100
    @@ -7245,10 +7246,11 @@
             }
             else
             {
    - if ((ch != '{') && (ch != '}')) // don't choke if there is no data (malformed RTF)
    - { // see bug 1383 and 1384
    - return false;
    - }
    + do
    + {
    + if (!ReadCharFromFile(&ch))
    + return false;
    + } while (ch != '}' && ch != '{');
     
                     // multiple entries in font table
                     while (ch != '}')



    This archive was generated by hypermail 2.1.4 : Tue Jun 24 2003 - 17:19:06 EDT