[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenetwork/kopete/protocols/yahoo
From:       Richard Smith <kde () metafoo ! co ! uk>
Date:       2004-12-03 18:33:57
Message-ID: 20041203183357.1C2C11B5AA () office ! kde ! org
[Download RAW message or body]

CVS commit by lilachaze: 

Various message parsing fixes:
<font> tags left in message, and correctly closed.
Custom colour parsing no longer leaves behind an 'm' (fixes part of #93687)
Italic messages no longer give XML error.

CCBUG: 93687
CCMAIL: mattr@kde.org (Mr Backports)


  M +47 -44    yahooaccount.cpp   1.109


--- kdenetwork/kopete/protocols/yahoo/yahooaccount.cpp  #1.108:1.109
@@ -118,17 +118,24 @@ QString YahooAccount::stripMsgColorCodes
 {
         QString filteredMsg = msg;
-        filteredMsg.remove(QRegExp("\033\\[(..m|#......)"));
 
         //Handle bold, underline and italic messages
-        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>" );
-        filteredMsg.replace( QRegExp("\033\\[4m"), "<u>" );
-        filteredMsg.replace( QRegExp("\033\\[x4m"), "</u>" );
+        filteredMsg.replace( "\033[1m", "<b>" );
+        filteredMsg.replace( "\033[x1m", "</b>" );
+        filteredMsg.replace( "\033[2m", "<i>" );
+        filteredMsg.replace( "\033[x2m", "</i>" );
+        filteredMsg.replace( "\033[4m", "<u>" );
+        filteredMsg.replace( "\033[x4m", "</u>" );
+        
+        //GAIM doesn't check for ^[[3m. Does this ever get sent?
+        filteredMsg.replace( "\033[3m", "<i>" );
+        filteredMsg.replace( "\033[x3m", "</i>" );
+        
+        //Strip link tags
+        filteredMsg.remove( "\033[lm" );
+        filteredMsg.remove( "\033[xlm" );
+        
+        //Remove color codes and other residual formatting
+        filteredMsg.remove( QRegExp("\033\\[[^m]*m") );
+        
         return filteredMsg;
 }
@@ -578,16 +585,14 @@ void YahooAccount::slotGotIm( const QStr
     kdDebug(14180) << "Message after stripping color codes '" << newMsgText << "'" << endl;
 
-        if (newMsgText.find("<font") != -1)
+        newMsgText.replace("<font","</font><font");
+        // if message contained <font>, remove first </font> and add </font> to end
+        int index = newMsgText.find("</font>");
+        if ( index != -1 )
         {
-                msgFont.setFamily(newMsgText.section('"', 1,1));
-
-                if (newMsgText.find("size"))
-                        msgFont.setPointSize(newMsgText.section('"', 3,3).toInt());
-
-                //remove the font encoding since we handle them ourselves
-                newMsgText.remove(newMsgText.mid(0, newMsgText.find('>')+1));
+                newMsgText.remove(index, 7);
+                newMsgText.append("</font>");
         }
 
-    kdDebug(14180) << "Message after removing font tags '" << newMsgText << "'" << endl;
+        kdDebug(14180) << "Message after fixing font tags '" << newMsgText << "'" << endl;
 
         Kopete::ChatSession *mm = contact(who)->manager(Kopete::Contact::CanCreate);
@@ -602,7 +607,5 @@ void YahooAccount::slotGotIm( const QStr
 
         kmsg.setFg( fgColor );
-        kmsg.setFont(msgFont);
         mm->appendMessage(kmsg);
-
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic