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

List:       kopete-devel
Subject:    Re: [kopete-devel] kdenetwork/kopete/protocols/oscar/oscarsocket
From:       Richard Smith <kde () metafoo ! co ! uk>
Date:       2004-10-05 19:56:35
Message-ID: 200410052101.27398.kde () metafoo ! co ! uk
[Download RAW message or body]

On Tuesday 05 October 2004 20:18, Matt Rogers wrote:
> On Tue, Oct 05, 2004 at 07:56:33PM +0200, Richard Smith wrote:
> > CVS commit by lilachaze:
> >
> > Check for out-of-range color and font indices a bit better.
> > Fix an off-by-one error giving wrong background colours according to RTF
> > spec.
> > CCMAIL: kopete-devel@kde.org
>
> Can you commit the same to the groupwise plugin? It uses the same RTF as
> oscar.

Groupwise's rtf.ll is not the same as Oscar's. In particular:

--- groupwise/libgroupwise/rtf.ll      2004-09-10 17:09:27.000000000 +0100
+++ oscar/oscarsocket/rtf.ll      2004-10-05 18:29:02.000000000 +0100
@@ -48,7 +48,7 @@
 "{"                            { return UP; }
 "}"                            { return DOWN; }
 "\\"[\\\{\}]                   { return SLASH; }
-"\\u"[0-9]{3,7}[ ]?"?"         { return UNICODE_CHAR; }
+"\\u"[0-9]{3,7}"?"             { return UNICODE_CHAR; }
 "\\"[A-Za-z]+[0-9]*[ ]?        { return CMD; }
 "\\'"[0-9A-Fa-f][0-9A-Fa-f]    { return HEX; }
 "<##"[^>]+">"                  { return IMG; }

The commit message in Groupwise was:

Fix decoding of escaped unicode in the RTF from Xplat. Translation: Russian, 
Hebrew, Chinese, and all other non-western-european alphabets are now 
displayed.

I'm guessing that oscarsocket's copy wants this too. Better, the two protocols 
should share this code. We could punt it over to libkopete, I guess.

> Sending me a patch would also be nice (so i can keep oscar_rewrite up to
> date), but it's not necessary, as i'll sync with CVS when i get to that
> part.

Attached is a diff for both the .ll and the .cc.

Richard

["diff" (text/x-diff)]

Index: rtf.ll
===================================================================
RCS file: /home/kde/kdenetwork/kopete/protocols/oscar/oscarsocket/rtf.ll,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -p -r1.4 -r1.5
--- rtf.ll	13 Jul 2004 20:47:46 -0000	1.4
+++ rtf.ll	5 Oct 2004 17:56:33 -0000	1.5
@@ -125,7 +125,7 @@ void RTF2HTML::FlushOutTags()
         case TAG_FONT_COLOR:
             {
                // RTF colors are 1-based; colors[] is a 0-based array.
-               if (t.param > colors.size())
+               if (t.param > colors.size() || t.param == 0)
                    break;
                QColor &c = colors[t.param-1];
                PrintUnquoted("<span style=\"color:#%02X%02X%02X\">", c.red(), \
c.green(), c.blue()); @@ -136,15 +136,17 @@ void RTF2HTML::FlushOutTags()
             break;
         case TAG_FONT_FAMILY:
             {
+               if (t.param > fonts.size() || t.param == 0)
+                   break;
                FontDef &f = fonts[t.param-1];
                string name = (!f.nonTaggedName.empty()) ? f.nonTaggedName : \
                f.taggedName;
                PrintUnquoted("<span style=\"font-family:%s\">", name.c_str());
             }
             break;
         case TAG_BG_COLOR:{
-               if (t.param > colors.size())
+               if (t.param > colors.size() || t.param == 0)
                    break;
-                QColor &c = colors[t.param];
+                QColor &c = colors[t.param-1];
                 PrintUnquoted("<span style=\"background-color:#%02X%02X%02X;\">", \
c.red(), c.green(), c.blue());  break;
             }
Index: rtf.cc
===================================================================
RCS file: /home/kde/kdenetwork/kopete/protocols/oscar/oscarsocket/rtf.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -p -r1.4 -r1.5
--- rtf.cc	28 Sep 2004 00:29:03 -0000	1.4
+++ rtf.cc	5 Oct 2004 17:56:33 -0000	1.5
@@ -1790,7 +1790,7 @@ void RTF2HTML::FlushOutTags()
         case TAG_FONT_COLOR:
             {
                // RTF colors are 1-based; colors[] is a 0-based array.
-               if (t.param > colors.size())
+               if (t.param > colors.size() || t.param == 0)
                    break;
                QColor &c = colors[t.param-1];
                PrintUnquoted("<span style=\"color:#%02X%02X%02X\">", c.red(), \
c.green(), c.blue()); @@ -1801,15 +1801,17 @@ void RTF2HTML::FlushOutTags()
             break;
         case TAG_FONT_FAMILY:
             {
+               if (t.param > fonts.size() || t.param == 0)
+                   break;
                FontDef &f = fonts[t.param-1];
                string name = (!f.nonTaggedName.empty()) ? f.nonTaggedName : \
                f.taggedName;
                PrintUnquoted("<span style=\"font-family:%s\">", name.c_str());
             }
             break;
         case TAG_BG_COLOR:{
-               if (t.param > colors.size())
+               if (t.param > colors.size() || t.param == 0)
                    break;
-                QColor &c = colors[t.param];
+                QColor &c = colors[t.param-1];
                 PrintUnquoted("<span style=\"background-color:#%02X%02X%02X;\">", \
c.red(), c.green(), c.blue());  break;
             }



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


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

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