Bug 75646 - XML document could not be parsed!
Summary: XML document could not be parsed!
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: general (show other bugs)
Version: 0.8.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-19 21:18 UTC by Jacob Mather
Modified: 2004-02-19 22:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Mather 2004-02-19 21:18:28 UTC
Version:           0.8.0 (using KDE KDE 3.2.0)
Installed from:    Gentoo Packages
Compiler:          GCC ~3.3.2 CFLAGS="-O3 -march=pentium4 -funroll-loops -fprefetch-loop-arrays -pipe"
OS:          Linux

Alright, I haven't seen anything on this specific issue, so I will detail as much as possible.

This only happens with very few people online, and only on Yahoo that I have noticed. I would guess it's a 3rd party app for YMessenger on win32. Here's the error:

An internal Kopete error occurred while parsing a message:
XML document could not be parsed!

I built a custom XSLT, and thought it might be that, but no go... still errors on any other XSLT.

Here's the file... RTPG = removed to protect the guilty...

<document><message direction="0" importance="1" subject="" mainContactId="RTPG" timestamp="Thu Feb 19 14:58:24 2004" time="02:58:24 pm" >
 <from>
  <contact contactId="RTPG" protocolIcon="/usr/kde/3.2/share/apps/kopete/icons/crystalsvg/16x16/apps/yahoo_protocol.png" color="deeppink" >
   <contactDisplayName dir="ltr" text="RTPG" />
   <metaContactDisplayName dir="ltr" text="RTPG" />
  </contact>
 </from>
 <to>
  <contact contactId="deadwatch" protocolIcon="/usr/kde/3.2/share/apps/kopete/icons/crystalsvg/16x16/apps/yahoo_protocol.png" >
   <contactDisplayName dir="ltr" text="deadwatch" />
   <metaContactDisplayName dir="ltr" text="deadwatch" />
  </contact>
 </to>
 <body dir="ltr" color="#000000" font="font-family: Comic Sans MS; " ><![CDATA[[1m<font face="Comic Sans MS">finally u arent busy</ALT>]]></body>
</message>
<message direction="0" importance="1" subject="" mainContactId="RTPG" timestamp="Thu Feb 19 14:58:24 2004" time="02:58:24 pm" >
 <from>
  <contact contactId="RTPG" protocolIcon="/usr/kde/3.2/share/apps/kopete/icons/crystalsvg/16x16/apps/yahoo_protocol.png" color="deeppink" >
   <contactDisplayName dir="ltr" text="RTPG" />
   <metaContactDisplayName dir="ltr" text="RTPG" />
  </contact>
 </from>
 <to>
  <contact contactId="deadwatch" protocolIcon="/usr/kde/3.2/share/apps/kopete/icons/crystalsvg/16x16/apps/yahoo_protocol.png" >
   <contactDisplayName dir="ltr" text="deadwatch" />
   <metaContactDisplayName dir="ltr" text="deadwatch" />
  </contact>
 </to>
 <body dir="ltr" color="#000000" font="font-family: Comic Sans MS; " ><![CDATA[[1m<font face="Comic Sans MS"><img align="center" width="22" height="22" src="/usr/kde/3.2/share/apps/kopete/pics/emoticons/Default/teeth.png" title=":D"/></ALT>]]></body>
</message>
</document>

I think it looks like something to do with...

<![CDATA[[1m<font face="Comic

It's sending some junk data or something, I don't know.
Comment 1 Richard Smith 2004-02-19 21:27:55 UTC
FYI: the <![CDATA[ is Kopete. The (box)[1m is a Yahoo! colour code. Kopete doesn't strip them out properly.

*** This bug has been marked as a duplicate of 75497 ***
Comment 2 Richard Smith 2004-02-19 22:24:40 UTC
Not really a dup since they have different causes... and I can fix this one :)
Comment 3 Richard Smith 2004-02-19 22:25:00 UTC
Mine!
Comment 4 Richard Smith 2004-02-19 22:28:30 UTC
CVS commit by lilachaze: 

Strip out Yahoo! colour codes from message body. As a side bonus, improve
colour code detection. [BACKPORT]
CCMAIL: 75646-done@bugs.kde.org


  M +19 -15    yahooaccount.cpp   1.63.2.1
  M +4 -0      yahooaccount.h   1.28.4.1


--- kdenetwork/kopete/protocols/yahoo/yahooaccount.cpp  #1.63:1.63.2.1
@@ -23,4 +23,5 @@
 #include <qdatetime.h>
 #include <qcolor.h>
+#include <qregexp.h>
 
 // KDE
@@ -123,4 +124,9 @@ void YahooAccount::setImportContacts(boo
 }
 
+QString YahooAccount::stripMsgColorCodes(const QString& msg)
+{
+        return QString(msg).remove(QRegExp("\033\\[(..m|#......)"));
+}
+
 QColor YahooAccount::getMsgColor(const QString& msg)
 {
@@ -128,29 +134,27 @@ QColor YahooAccount::getMsgColor(const Q
          * so we have to use this really hacky method to get colors
          */
-        kdDebug(14180) << k_funcinfo << "msg is " << msg << endl;
-        //If we get here, the message uses a standard Yahoo color
-        //(selectable from the drop down box)
+        //kdDebug(14180) << k_funcinfo << "msg is " << msg << endl;
         //Please note that some of the colors are hard-coded to
         //match the yahoo colors
-        if ( msg.find("[38m") != -1 )
+        if ( msg.find("\033[38m") != -1 )
                 return Qt::red;
-        if ( msg.find("[34m") != -1 )
+        if ( msg.find("\033[34m") != -1 )
                 return Qt::green;
-        if ( msg.find("[31m") != -1 )
+        if ( msg.find("\033[31m") != -1 )
                 return Qt::blue;
-        if ( msg.find("[39m") != -1 )
+        if ( msg.find("\033[39m") != -1 )
                 return Qt::yellow;
-        if ( msg.find("[36m") != -1 )
+        if ( msg.find("\033[36m") != -1 )
                 return Qt::darkMagenta;
-        if ( msg.find("[32m") != -1 )
+        if ( msg.find("\033[32m") != -1 )
                 return Qt::cyan;
-        if ( msg.find("[37m") != -1 )
+        if ( msg.find("\033[37m") != -1 )
                 return QColor("#FFAA39");
-        if ( msg.find("[35m") != -1 )
+        if ( msg.find("\033[35m") != -1 )
                 return QColor("#FFD8D8");
-        if ( msg.find("[#") != -1 )
+        if ( msg.find("\033[#") != -1 )
         {
-                kdDebug(14180) << "Custom color is " << msg.mid(msg.find("[#")+1,7) << endl;
-                return QColor(msg.mid(msg.find("[#")+1,7));
+                kdDebug(14180) << "Custom color is " << msg.mid(msg.find("\033[#")+2,7) << endl;
+                return QColor(msg.mid(msg.find("\033[#")+2,7));
         }
         
@@ -482,5 +486,5 @@ void YahooAccount::slotGotIm( const QStr
                                         KopeteMessage::Inbound , KopeteMessage::PlainText);
 
-        QString newMsg = kmsg.plainBody();
+        QString newMsg = stripMsgColorCodes(kmsg.plainBody());
         
         kmsg.setFg(getMsgColor(msg));

--- kdenetwork/kopete/protocols/yahoo/yahooaccount.h  #1.28:1.28.4.1
@@ -123,4 +123,8 @@ protected:
          */
         QColor getMsgColor(const QString& msg);
+        /**
+         * Remove color codes from a message
+         */
+        QString stripMsgColorCodes(const QString& msg);
         
 protected slots: