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

Mark Doliner mark at kingant.net
Sat Aug 22 19:51:35 EDT 2009


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.

-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;
>
>
> _______________________________________________
> Commits mailing list
> Commits at pidgin.im
> http://pidgin.im/cgi-bin/mailman/listinfo/commits
>




More information about the Devel mailing list