pidgin: e9fdd89a: jabber: Strip the '/' off of a JID in ja..

Elliott Sales de Andrade qulogic at pidgin.im
Sat Aug 22 20:11:30 EDT 2009


On Sat, Aug 22, 2009 at 7:51 PM, Mark Doliner <mark at kingant.net> wrote:

> Hmm, is this change ONLY needed to handle the case where our JID ends
> in a slash?  I wonder if there is another way we could fix this...
> like maybe not appending the slash?  Or appending a default resource?
> Or changing jabber_id_new() to ignore a trailing slash?  I'm afraid
> that Jabber's normalize function gets called often and the extra
> strlen and strdup could be expensive.
>

I can't say what's required here, but I can simplify it a bit:

if (in[len - 1] == '/')
    in[len - 1] = '\0';

It won't remove the strlen, but it gets rid of the strdup and free.

-Mark
>
> On Fri, Aug 21, 2009 at 11:25 PM, <darkrain42 at pidgin.im> wrote:
> > -----------------------------------------------------------------
> > Revision: e9fdd89af79c9970da8f644c0aef24cecf43fed8
> > Ancestor: fdf3ae9383614c0dc53e1d9b17637e50e0819acb
> > Author: darkrain42 at pidgin.im
> > Date: 2009-08-22T06:00:18
> > Branch: im.pidgin.pidgin
> > URL:
> http://d.pidgin.im/viewmtn/revision/info/e9fdd89af79c9970da8f644c0aef24cecf43fed8
> >
> > Modified files:
> >        libpurple/protocols/jabber/jutil.c
> >
> > ChangeLog:
> >
> > jabber: Strip the '/' off of a JID in jabber_normalize.
> >
> > This is what Pidgin did pre-2.6.0 and breaks the log directories for
> > accounts with no resource. Closes #9959.
> >
> >
> > ============================================================
> > --- libpurple/protocols/jabber/jutil.c
>  a8cbf30acbf26b6f9c31c79938b684abc969ef78
> > +++ libpurple/protocols/jabber/jutil.c
>  ac608eab4a23bf8aac38a987c7e1c36cc654938f
> > @@ -506,9 +506,24 @@ const char *jabber_normalize(const Purpl
> >        JabberStream *js = gc ? gc->proto_data : NULL;
> >        static char buf[3072]; /* maximum legal length of a jabber jid */
> >        JabberID *jid;
> > +       char *tmp;
> > +       size_t len = strlen(in);
> >
> > -       jid = jabber_id_new(in);
> > +       /*
> > +        * If the JID ends with a '/', jabber_id_new is going to throw it
> away as
> > +        * invalid.  However, this is what the UI generates for a JID
> with no
> > +        * resource. Deal with that by dropping away the '/'...
> > +        */
> > +       if (in[len - 1] == '/')
> > +               tmp = g_strndup(in, len - 1);
> > +       else
> > +               tmp = (gchar *)in;
> >
> > +       jid = jabber_id_new(tmp);
> > +
> > +       if (tmp != in)
> > +               g_free(tmp);
> > +
> >        if(!jid)
> >                return NULL;
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20090822/6ee12a00/attachment.html>


More information about the Devel mailing list