patch -- bug 682


Subject: patch -- bug 682
From: sam th (sam@bur-jud-118-039.rh.uchicago.edu)
Date: Tue Jan 18 2000 - 00:33:20 CST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

this patch tests to make sure that images that purport to be png format
actually are (b/c if they aren't, abiword segfaults). this adds
additional code in ap_EditMethods.cpp, but i have yet to get any
suggestions as to where to put these functions.

           
                                     sam th
                                     sytobinh@uchicago.edu
                                        
diff -ru -x CVS abi/CREDITS.TXT abi-bak/CREDITS.TXT
- --- abi/CREDITS.TXT Fri Jan 14 01:45:02 2000
+++ abi-bak/CREDITS.TXT Mon Jan 17 10:53:53 2000
@@ -48,7 +48,7 @@
 Dan Schreiber <dan@abisource.com>
 <kstailey@kstailey.tzo.com> OpenBSD
 Nigel Stepp <stepp@mithril.res.cmu.edu> VI keybindings
- -Sam Th <sytobinh@uchicago.edu> File I/O error handling
+Sam Tobin-Hochstadt <sytobinh@uchicago.edu> File I/O error handling
 Gary Thomas <gdt@linuxppc.org> LinuxPPC
 Dave Thompson <thompson@pdnt.com>
 Robert G. Werner <rwerner@lx1.microbsys.com> VI keybindings
Only in abi-bak/src/af/util/xp: .#ut_types.h.1.26
diff -ru -x CVS abi/src/af/util/xp/ut_types.h abi-bak/src/af/util/xp/ut_types.h
- --- abi/src/af/util/xp/ut_types.h Mon Jan 17 15:59:14 2000
+++ abi-bak/src/af/util/xp/ut_types.h Mon Jan 17 20:07:51 2000
@@ -68,12 +68,13 @@
 #define UT_SaveExportError ((UT_ErrorCode) -203)
 #define UT_SaveOtherError ((UT_ErrorCode) -200) // This should eventually dissapear.
 #define UT_IE_FileNotFound ((UT_ErrorCode) -301)
- -#define UT_IE_NoMemory ((UT_ErrorCode) -301)
- -#define UT_IE_UnkownType ((UT_ErrorCode) -301)
- -#define UT_IE_BogusDocument ((UT_ErrorCode) -301)
- -#define UT_IE_CouldNotOpen ((UT_ErrorCode) -301)
- -#define UT_IE_CouldNotWrite ((UT_ErrorCode) -301)
- -#define UT_IE_ImportError ((UT_ErrorCode) -301) // The general case
+#define UT_IE_NoMemory ((UT_ErrorCode) -302)
+#define UT_IE_UnknownType ((UT_ErrorCode) -303)
+#define UT_IE_BogusDocument ((UT_ErrorCode) -304)
+#define UT_IE_CouldNotOpen ((UT_ErrorCode) -305)
+#define UT_IE_CouldNotWrite ((UT_ErrorCode) -306)
+#define UT_IE_FakeType ((UT_ErrorCode) -307)
+#define UT_IE_ImportError ((UT_ErrorCode) -300) // The general case
 
 
 /*
Only in abi-bak/src/text/ptbl/xp: .#pd_Document.cpp.1.64
diff -ru -x CVS abi/src/wp/ap/xp/ap_EditMethods.cpp abi-bak/src/wp/ap/xp/ap_EditMethods.cpp
- --- abi/src/wp/ap/xp/ap_EditMethods.cpp Mon Jan 17 15:59:15 2000
+++ abi-bak/src/wp/ap/xp/ap_EditMethods.cpp Mon Jan 17 22:22:18 2000
@@ -1150,7 +1150,7 @@
             break;
 
           case -303:
- - pDialog->setMessage(pSS->getValue(AP_STRING_ID_MSG_IE_UnkownType),pNewFile);
+ pDialog->setMessage(pSS->getValue(AP_STRING_ID_MSG_IE_UnknownType),pNewFile);
             break;
 
           case -304:
@@ -1165,6 +1165,10 @@
             pDialog->setMessage(pSS->getValue(AP_STRING_ID_MSG_IE_CouldNotWrite),pNewFile);
             break;
 
+ case -307:
+ pDialog->setMessage(pSS->getValue(AP_STRING_ID_MSG_IE_FakeType),pNewFile);
+ break;
+
           default:
             pDialog->setMessage(pSS->getValue(AP_STRING_ID_MSG_ImportError),pNewFile);
           }
@@ -1757,6 +1761,8 @@
 */
 #define ABIWORD_VIEW FV_View * pView = static_cast<FV_View *>(pAV_View)
 
+// I dislike the fact that these two functions are here, but have yet to find a better location
+
 UT_ErrorCode toErrorCode(IEStatus IES)
 {
   if (!IES)
@@ -1765,6 +1771,17 @@
     return ((300 + IES - 1) * -1);
 }
 
+UT_sint32 isPNG(const char * szFileName)
+{
+ FILE * fp = fopen(szFileName, "r");
+ char str[10] = "";
+ char str2[10] = "\211PNG";
+ fgets(str, 4, fp);
+ fclose(fp);
+ return (strncmp(str, str2, 4));
+
+}
+
 Defun1(fileInsertGraphic)
 {
         XAP_Frame * pFrame = (XAP_Frame *) pAV_View->getParentData();
@@ -1787,6 +1804,18 @@
 
         UT_ErrorCode errorCode;
 
+ // here we see that it is really a png file - this will have to be modified
+ // as we add support for new graphics types
+
+ UT_sint32 tmpVar = isPNG(pNewFile);
+ if(!(tmpVar == 0))
+ {
+ errorCode = UT_IE_FakeType;
+ s_CouldNotLoadFileMessage(pFrame, pNewFile, errorCode);
+ FREEP(pNewFile);
+ return UT_FALSE;
+ }
+
         errorCode = toErrorCode(IE_ImpGraphic::constructImporter(pNewFile, iegft, &pIEG));
         if(errorCode)
           {
@@ -1794,7 +1823,7 @@
                 FREEP(pNewFile);
                 return UT_FALSE;
           }
- -
+
         errorCode = toErrorCode(pIEG->importGraphic(pNewFile, &pFG));
         if(errorCode)
           {
diff -ru -x CVS abi/src/wp/ap/xp/ap_String_Id.h abi-bak/src/wp/ap/xp/ap_String_Id.h
- --- abi/src/wp/ap/xp/ap_String_Id.h Mon Jan 17 15:59:16 2000
+++ abi-bak/src/wp/ap/xp/ap_String_Id.h Mon Jan 17 20:02:59 2000
@@ -30,16 +30,17 @@
 dcl(MSG_SaveFailedExport, "Error while attempting to save %s: could not construct exporter")
 dcl(MSG_SaveFailedName, "Error while attempting to save %s: invalid name")
 dcl(MSG_DlgNotImp, "%s not implemented yet.\n\nIf you are a programmer, feel free to add code in %s, line %d\nand mail patches to:\n\n\tabiword-dev@abisource.com\n\nOtherwise, please be patient.")
- -dcl(MSG_RevertBuffer, "Revert to saved copy of %s?")
+dcl(MSG_RevertBuffer, "Revert to saved copy of %s?")
 dcl(MSG_QueryExit, "Close all windows and exit?")
- -dcl(MSG_ConfirmSave, "Save changes to %s?")
- -dcl(MSG_ImportError, "Error importing file %s.")
- -dcl(MSG_IE_FileNotFound, "File %s not found")
- -dcl(MSG_IE_NoMemory, "Out of memory attempting to open %s")
- -dcl(MSG_IE_UnkownType, "File %s is of unkown type")
- -dcl(MSG_IE_BogusDocument, "File %s is a bogus document")
- -dcl(MSG_IE_CouldNotOpen, "Could not open file %s for writing")
- -dcl(MSG_IE_CouldNotWrite, "Could not write to file %s")
+dcl(MSG_ConfirmSave, "Save changes to %s?")
+dcl(MSG_ImportError, "Error importing file %s.")
+dcl(MSG_IE_FileNotFound, "File %s not found")
+dcl(MSG_IE_NoMemory, "Out of memory attempting to open %s")
+dcl(MSG_IE_UnknownType, "File %s is of unkown type")
+dcl(MSG_IE_FakeType, "File %s is not of the type it claims to be")
+dcl(MSG_IE_BogusDocument, "File %s is a bogus document")
+dcl(MSG_IE_CouldNotOpen, "Could not open file %s for writing")
+dcl(MSG_IE_CouldNotWrite, "Could not write to file %s")
 dcl(MSG_SpellDone, "The spelling check is complete.")
 
 // Status Bar Messages
diff -ru -x CVS abi/src/wp/impexp/xp/ie_exp_HTML.cpp abi-bak/src/wp/impexp/xp/ie_exp_HTML.cpp
- --- abi/src/wp/impexp/xp/ie_exp_HTML.cpp Fri Dec 3 16:52:47 1999
+++ abi-bak/src/wp/impexp/xp/ie_exp_HTML.cpp Tue Jan 18 00:22:06 2000
@@ -708,7 +708,7 @@
         m_bInSpan = UT_FALSE;
         
         m_pie->write("<!-- ================================================================================ -->\n");
- - m_pie->write("<!-- This HTML file was created by AbiWord. -->\n");
+ m_pie->write("<!-- This HTML file was created by AbiWord. -->\n");
         m_pie->write("<!-- AbiWord is a free, Open Source word processor. -->\n");
         m_pie->write("<!-- You may obtain more information about AbiWord at www.abisource.com -->\n");
         m_pie->write("<!-- ================================================================================ -->\n");
diff -ru -x CVS abi/user/wp/strings/CaES.strings abi-bak/user/wp/strings/CaES.strings
- --- abi/user/wp/strings/CaES.strings Mon Jan 17 15:45:42 2000
+++ abi-bak/user/wp/strings/CaES.strings Mon Jan 17 16:41:32 2000
@@ -84,7 +84,7 @@
 MSG_QueryExit="Voleu tancar totes les finestres i sortir?"
 MSG_ConfirmSave="Voleu desar els canvis fets a %s?"
 MSG_ImportError="Error d'importació al fitxer %s."
- -MSG_DlgNotImp, "%s not implemented yet.\n\nIf you are a programmer, feel free to add code in %s, line %d\nand mail patches to:\n\n\tabiword-dev@abisource.com\n\nOtherwise, please be patient."
+MSG_DlgNotImp="%s not implemented yet.\n\nIf you are a programmer, feel free to add code in %s, line %d\nand mail patches to:\n\n\tabiword-dev@abisource.com\n\nOtherwise, please be patient."
 PageInfoField="Pàgina: %d/%d"
 DLG_FR_FindTitle="Cerca"
 DLG_FR_ReplaceTitle="Reemplaça"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE4hAkxt+kM0Mq9M/wRApbsAJ4hWFfImAjdA1j7Kp6S9ovt2HpLqwCgjQWT
xQigskpEeydVZiwrlX6uvu8=
=pMa4
-----END PGP SIGNATURE-----




This archive was generated by hypermail 2b25 : Tue Jan 18 2000 - 00:33:19 CST