[Libreoffice-commits] .: starmath/source

Tor Lillqvist tml at kemper.freedesktop.org
Tue Aug 14 03:41:34 PDT 2012


 starmath/source/smdetect.cxx |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit aa4b8a8164f01a120ba9bfb2e86b1ed33cc1d69c
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Tue Aug 14 12:33:52 2012 +0200

    Be more careful in recognizing MathML (bnc#774921)
    
    Change-Id: I82c36a3ff49f74dc674df46dcf35f8c1a991c9e2

diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx
index 5a36375..da11ce6 100644
--- a/starmath/source/smdetect.cxx
+++ b/starmath/source/smdetect.cxx
@@ -312,10 +312,20 @@ SmFilterDetect::~SmFilterDetect()
                         {
                             if (0 == strncmp( "<?xml",aBuffer,nSize))
                             {
-                                static const sal_Char sFltrNm_2[] = MATHML_XML;
-                                static const sal_Char sTypeNm_2[] = "math_MathML_XML_Math";
-                                aFilterName.AssignAscii( sFltrNm_2 );
-                                aTypeName.AssignAscii( sTypeNm_2 );
+                                // 200 should be enough for the XML
+                                // version, encoding and !DOCTYPE
+                                // stuff I hope?
+                                sal_Char aBuffer2[200];
+                                nBytesRead = pStrm->Read( aBuffer2, sizeof(aBuffer2) - 1);
+                                aBuffer2[nBytesRead] = 0;
+                                if (strstr( aBuffer2, "<math>" ) != NULL ||
+                                    strstr( aBuffer2, "<math " ) != NULL)
+                                {
+                                    static const sal_Char sFltrNm_2[] = MATHML_XML;
+                                    static const sal_Char sTypeNm_2[] = "math_MathML_XML_Math";
+                                    aFilterName.AssignAscii( sFltrNm_2 );
+                                    aTypeName.AssignAscii( sTypeNm_2 );
+                                }
                             }
                         }
                     }


More information about the Libreoffice-commits mailing list