From: Fridrich S. <str...@us...> - 2010-06-07 08:25:12
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv21206/src/lib Modified Files: WPGHeader.cpp WPGraphics.cpp Log Message: Trying to handle some invalid documents that libwpd's dumping mechanism created due to a bug Index: WPGraphics.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGraphics.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- WPGraphics.cpp 30 Dec 2008 08:53:57 -0000 1.16 +++ WPGraphics.cpp 7 Jun 2010 08:25:01 -0000 1.17 @@ -56,6 +56,8 @@ } else graphics = input; + + graphics->seek(0, WPX_SEEK_SET); WPGHeader header; if(!header.load(graphics)) @@ -97,6 +99,8 @@ } else graphics = input; + + graphics->seek(0, WPX_SEEK_SET); WPG_DEBUG_MSG(("Loading header...\n")); unsigned char tmpMajorVersion = 0x00; @@ -124,6 +128,19 @@ // seek to the start of document graphics->seek(header.startOfDocument(), WPX_SEEK_SET); tmpMajorVersion = (unsigned char)(header.majorVersion()); + if (tmpMajorVersion == 0x01) + { + /* Due to a bug in dumping mechanism, we produced + * invalid WPG files by prepending a WPG1 header + * to a valid WP file. Let us check this kind of files, + * so that we can load our own mess too. */ + if (header.load(graphics) && header.isSupported()) + { + WPG_DEBUG_MSG(("An invalid graphics we produced :(\n")); + graphics->seek(header.startOfDocument() + 16, WPX_SEEK_SET); + tmpMajorVersion = (unsigned char)(header.majorVersion()); + } + } } else // here we force parsing of headerless pictures Index: WPGHeader.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGHeader.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- WPGHeader.cpp 30 Dec 2008 08:53:57 -0000 1.7 +++ WPGHeader.cpp 7 Jun 2010 08:25:01 -0000 1.8 @@ -65,7 +65,7 @@ bool WPGHeader::load(WPXInputStream *input) { - input->seek(0, WPX_SEEK_SET); +// input->seek(0, WPX_SEEK_SET); unsigned long n = 0; unsigned char * prefix = (unsigned char *) input->read(26, n); |