Bug 87190 - Kopete parse error on URLs
Summary: Kopete parse error on URLs
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: Yahoo Plugin (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
: 90257 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-08-14 13:22 UTC by Jes Hall
Modified: 2004-09-26 16:03 UTC (History)
1 user (show)

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 Jes Hall 2004-08-14 13:22:29 UTC
Version:           0.8.4 (using KDE 3.2.3, compiled sources)
Compiler:          gcc version 3.3.3
OS:                Linux (i686) release 2.4.26

When I'm sent a url from a friend using Gaim Win32 on windows 2000, on the yahoo protocol, I get 
"An internal Kopete error occurred while parsing a message:
XML document could not be parsed!"

This occurs using any of the stylesheets included with Kopete.

The same person is able to send me url's without a problem from AIM or ICQ.
Comment 1 Matt Rogers 2004-08-14 17:34:44 UTC
do you have debug output?
Comment 2 Jes Hall 2004-08-15 02:39:01 UTC
I don't, I don't know how to. 
Comment 3 Matt Rogers 2004-08-15 02:41:05 UTC
ok, no worries. Can you give me the url the person was trying to send you?

Comment 4 Jes Hall 2004-08-15 02:43:10 UTC
of course. It was a number of URLs, but this was one of them

http://www.lowendmac.com/pb2/2300.shtml
Comment 5 Matt Rogers 2004-08-20 06:27:44 UTC
CVS commit by mattr: 

Rearrange the message parsing a bit so we do it all before we create the
KopeteMessage object for it. 

Workaround gaim's bugginess when sending URLs so that there aren't parse
errors.

CCMAIL: 87190@bugs.kde.org


  M +55 -46    yahooaccount.cpp   1.94


--- kdenetwork/kopete/protocols/yahoo/yahooaccount.cpp  #1.93:1.94
@@ -121,4 +121,8 @@ QString YahooAccount::stripMsgColorCodes
         filteredMsg.replace( QRegExp("\033\\[1m"), "<b>" );
         filteredMsg.replace( QRegExp("\033\\[x1m"), "</b>" );
+    //work around gaim's broken sending
+    filteredMsg.remove( QRegExp( "\033\\[xlm" ) );
+    filteredMsg.remove( QRegExp( "\033\\[lm" ) );
+    //end work around
         filteredMsg.replace( QRegExp("\033\\[3m"), "<i>" );
         filteredMsg.replace( QRegExp("\033\\[x3m"), "</i>" );
@@ -610,11 +614,8 @@ void YahooAccount::slotGotIm( const QStr
         }
 
-        KopeteMessageManager *mm = contact(who)->manager();
-
-        // Tell the message manager that the buddy is done typing
-        mm->receivedTypingMsg(contact(who), false);
-
-        justMe.append(myself());
-
+    //Parse the message for it's properties
+    kdDebug(14180) << "Original message is '" << msg << "'" << endl;
+    //kdDebug(14180) << "Message color is " << getMsgColor(msg) << endl;
+    QColor fgColor = getMsgColor( msg );
         if (tm == 0)
                 msgDT.setTime_t(time(0L));
@@ -622,24 +623,32 @@ void YahooAccount::slotGotIm( const QStr
                 msgDT.setTime_t(tm, Qt::LocalTime);
 
-        KopeteMessage kmsg(msgDT, contact(who), justMe, msg,
-                                        KopeteMessage::Inbound , KopeteMessage::PlainText);
-
-        QString newMsg = stripMsgColorCodes(kmsg.plainBody());
+    QString newMsgText = stripMsgColorCodes( msg );
 
-        kmsg.setFg(getMsgColor(msg));
-//      kdDebug(14180) << "Message color is " << getMsgColor(msg) << endl;
+    kdDebug(14180) << "Message after stripping color codes '" << newMsgText << "'" << endl;
 
-        if (newMsg.find("<font") != -1)
+        if (newMsgText.find("<font") != -1)
         {
-                msgFont.setFamily(newMsg.section('"', 1,1));
+                msgFont.setFamily(newMsgText.section('"', 1,1));
 
-                if (newMsg.find("size"))
-                        msgFont.setPointSize(newMsg.section('"', 3,3).toInt());
+                if (newMsgText.find("size"))
+                        msgFont.setPointSize(newMsgText.section('"', 3,3).toInt());
 
                 //remove the font encoding since we handle them ourselves
-                newMsg.remove(newMsg.mid(0, newMsg.find('>')+1));
+                newMsgText.remove(newMsgText.mid(0, newMsgText.find('>')+1));
         }
-        //set the new body that has correct HTML
-        kmsg.setBody(newMsg, KopeteMessage::RichText);
+
+    kdDebug(14180) << "Message after removing font tags '" << newMsgText << "'" << endl;
+
+        KopeteMessageManager *mm = contact(who)->manager();
+
+        // Tell the message manager that the buddy is done typing
+        mm->receivedTypingMsg(contact(who), false);
+
+        justMe.append(myself());
+
+        KopeteMessage kmsg(msgDT, contact(who), justMe, newMsgText,
+                                        KopeteMessage::Inbound , KopeteMessage::RichText);
+
+        kmsg.setFg( fgColor );
         kmsg.setFont(msgFont);
         mm->appendMessage(kmsg);


Comment 6 Matt Rogers 2004-08-20 06:29:04 UTC
CVS commit by mattr: 

Backport of the fix for the parse errors when we've been sent URLs in yahoo.

This should be in KDE 3.3.1

CCMAIL: 87190-done@bugs.kde.org


  M +29 -20    yahooaccount.cpp   1.93.2.1


--- kdenetwork/kopete/protocols/yahoo/yahooaccount.cpp  #1.93:1.93.2.1
@@ -121,4 +121,8 @@ QString YahooAccount::stripMsgColorCodes
         filteredMsg.replace( QRegExp("\033\\[1m"), "<b>" );
         filteredMsg.replace( QRegExp("\033\\[x1m"), "</b>" );
+    //work around gaim's broken sending
+    filteredMsg.remove( QRegExp( "\033\\[xlm" ) );
+    filteredMsg.remove( QRegExp( "\033\\[lm" ) );
+    //end work around
         filteredMsg.replace( QRegExp("\033\\[3m"), "<i>" );
         filteredMsg.replace( QRegExp("\033\\[x3m"), "</i>" );
@@ -610,11 +614,8 @@ void YahooAccount::slotGotIm( const QStr
         }
 
-        KopeteMessageManager *mm = contact(who)->manager();
-
-        // Tell the message manager that the buddy is done typing
-        mm->receivedTypingMsg(contact(who), false);
-
-        justMe.append(myself());
-
+    //Parse the message for it's properties
+    kdDebug(14180) << "Original message is '" << msg << "'" << endl;
+    //kdDebug(14180) << "Message color is " << getMsgColor(msg) << endl;
+    QColor fgColor = getMsgColor( msg );
         if (tm == 0)
                 msgDT.setTime_t(time(0L));
@@ -622,24 +623,32 @@ void YahooAccount::slotGotIm( const QStr
                 msgDT.setTime_t(tm, Qt::LocalTime);
 
-        KopeteMessage kmsg(msgDT, contact(who), justMe, msg,
-                                        KopeteMessage::Inbound , KopeteMessage::PlainText);
-
-        QString newMsg = stripMsgColorCodes(kmsg.plainBody());
+    QString newMsgText = stripMsgColorCodes( msg );
 
-        kmsg.setFg(getMsgColor(msg));
-//      kdDebug(14180) << "Message color is " << getMsgColor(msg) << endl;
+    kdDebug(14180) << "Message after stripping color codes '" << newMsgText << "'" << endl;
 
-        if (newMsg.find("<font") != -1)
+        if (newMsgText.find("<font") != -1)
         {
-                msgFont.setFamily(newMsg.section('"', 1,1));
+                msgFont.setFamily(newMsgText.section('"', 1,1));
 
-                if (newMsg.find("size"))
-                        msgFont.setPointSize(newMsg.section('"', 3,3).toInt());
+                if (newMsgText.find("size"))
+                        msgFont.setPointSize(newMsgText.section('"', 3,3).toInt());
 
                 //remove the font encoding since we handle them ourselves
-                newMsg.remove(newMsg.mid(0, newMsg.find('>')+1));
+                newMsgText.remove(newMsgText.mid(0, newMsgText.find('>')+1));
         }
-        //set the new body that has correct HTML
-        kmsg.setBody(newMsg, KopeteMessage::RichText);
+
+    kdDebug(14180) << "Message after removing font tags '" << newMsgText << "'" << endl;
+
+        KopeteMessageManager *mm = contact(who)->manager();
+
+        // Tell the message manager that the buddy is done typing
+        mm->receivedTypingMsg(contact(who), false);
+
+        justMe.append(myself());
+
+        KopeteMessage kmsg(msgDT, contact(who), justMe, newMsgText,
+                                        KopeteMessage::Inbound , KopeteMessage::RichText);
+
+        kmsg.setFg( fgColor );
         kmsg.setFont(msgFont);
         mm->appendMessage(kmsg);


Comment 7 Matt Rogers 2004-09-26 16:03:31 UTC
*** Bug 90257 has been marked as a duplicate of this bug. ***