annotate libpurple/protocols/jabber/jutil.c @ 28506:2e3678cd33a0

jabber: Properly handle adding buddies that contain a resource. Closes #10151. Need to strip the resource when adding a buddy, so that the core doesn't think the buddy is named "juliet@capulet.lit/chamber", which apparently causes very strange issues.
author Paul Aurich <paul@darkrain42.org>
date Mon, 31 Aug 2009 03:39:34 +0000
parents 22c65c1090a8
children 4cb882afbd6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
2 * purple - Jabber Protocol Plugin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
28398
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27712
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27712
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27712
diff changeset
6 * source distribution.
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15891
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
15891
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
24 #include "account.h"
24641
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
25 #include "cipher.h"
15891
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
26 #include "conversation.h"
24641
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
27 #include "debug.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "server.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "util.h"
15891
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
30 #include "xmlnode.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "chat.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "presence.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "jutil.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
36 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
37 #include <idna.h>
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
38 #include <stringprep.h>
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
39 static char idn_buffer[1024];
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
40 #endif
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
41
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
42 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
43 static gboolean jabber_nodeprep(char *str, size_t buflen)
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
44 {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
45 return stringprep_xmpp_nodeprep(str, buflen) == STRINGPREP_OK;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
46 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
47
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
48 static gboolean jabber_resourceprep(char *str, size_t buflen)
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
49 {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
50 return stringprep_xmpp_resourceprep(str, buflen) == STRINGPREP_OK;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
51 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
52
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
53 static JabberID*
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
54 jabber_idn_validate(const char *str, const char *at, const char *slash,
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
55 const char *null)
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
56 {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
57 const char *node = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
58 const char *domain = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
59 const char *resource = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
60 int node_len = 0;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
61 int domain_len = 0;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
62 int resource_len = 0;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
63 char *out;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
64 JabberID *jid;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
65
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
66 /* Ensure no parts are > 1023 bytes */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
67 if (at) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
68 node = str;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
69 node_len = at - str;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
70
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
71 domain = at + 1;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
72 if (slash) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
73 domain_len = slash - (at + 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
74 resource = slash + 1;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
75 resource_len = null - (slash + 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
76 } else {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
77 domain_len = null - (at + 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
78 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
79 } else {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
80 domain = str;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
81
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
82 if (slash) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
83 domain_len = slash - str;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
84 resource = slash;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
85 resource_len = null - (slash + 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
86 } else {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
87 domain_len = null - (str + 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
88 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
89 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
90
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
91 if (node && node_len > 1023)
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
92 return NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
93 if (domain_len > 1023)
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
94 return NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
95 if (resource && resource_len > 1023)
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
96 return NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
97
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
98 jid = g_new0(JabberID, 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
99
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
100 if (node) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
101 strncpy(idn_buffer, node, node_len);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
102 idn_buffer[node_len] = '\0';
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
103
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
104 if (!jabber_nodeprep(idn_buffer, sizeof(idn_buffer))) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
105 jabber_id_free(jid);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
106 jid = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
107 goto out;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
108 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
109
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
110 jid->node = g_strdup(idn_buffer);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
111 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
112
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
113 /* domain *must* be here */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
114 strncpy(idn_buffer, domain, domain_len);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
115 idn_buffer[domain_len] = '\0';
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
116 if (domain[0] == '[') { /* IPv6 address */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
117 gboolean valid = FALSE;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
118
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
119 if (idn_buffer[domain_len - 1] == ']') {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
120 idn_buffer[domain_len - 1] = '\0';
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
121 valid = purple_ipv6_address_is_valid(idn_buffer + 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
122 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
123
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
124 if (!valid) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
125 jabber_id_free(jid);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
126 jid = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
127 goto out;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
128 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
129 } else {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
130 /* Apply nameprep */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
131 if (stringprep_nameprep(idn_buffer, sizeof(idn_buffer)) != STRINGPREP_OK) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
132 jabber_id_free(jid);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
133 jid = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
134 goto out;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
135 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
136
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
137 /* And now ToASCII */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
138 if (idna_to_ascii_8z(idn_buffer, &out, IDNA_USE_STD3_ASCII_RULES) != IDNA_SUCCESS) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
139 jabber_id_free(jid);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
140 jid = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
141 goto out;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
142 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
143
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
144 /* This *MUST* be freed using 'free', not 'g_free' */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
145 free(out);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
146 jid->domain = g_strdup(idn_buffer);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
147 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
148
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
149 if (resource) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
150 strncpy(idn_buffer, resource, resource_len);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
151 idn_buffer[resource_len] = '\0';
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
152
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
153 if (!jabber_resourceprep(idn_buffer, sizeof(idn_buffer))) {
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
154 jabber_id_free(jid);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
155 jid = NULL;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
156 /* goto out; */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
157 }
27712
e8ec4a3e6706 Oops, it helps to set the resource.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
158
e8ec4a3e6706 Oops, it helps to set the resource.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
159 jid->resource = g_strdup(idn_buffer);
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
160 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
161
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
162 out:
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
163 return jid;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
164 }
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
165
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
166 #endif /* USE_IDN */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
167
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 gboolean jabber_nodeprep_validate(const char *str)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
170 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
171 gboolean result;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
172 #else
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 const char *c;
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
174 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 if(!str)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 if(strlen(str) > 1023)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
182 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
183 strncpy(idn_buffer, str, sizeof(idn_buffer) - 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
184 idn_buffer[sizeof(idn_buffer) - 1] = '\0';
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
185 result = jabber_nodeprep(idn_buffer, sizeof(idn_buffer));
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
186 return result;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
187 #else /* USE_IDN */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 c = str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 while(c && *c) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 gunichar ch = g_utf8_get_char(c);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 if(ch == '\"' || ch == '&' || ch == '\'' || ch == '/' || ch == ':' ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 ch == '<' || ch == '>' || ch == '@' || !g_unichar_isgraph(ch)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 c = g_utf8_next_char(c);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 return TRUE;
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
199 #endif /* USE_IDN */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
202 gboolean jabber_domain_validate(const char *str)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 const char *c;
27548
f1f901b3d6f2 Save one traversal of the domain for IPv6 validation.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
205 size_t len;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 if(!str)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209
27548
f1f901b3d6f2 Save one traversal of the domain for IPv6 validation.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
210 len = strlen(str);
f1f901b3d6f2 Save one traversal of the domain for IPv6 validation.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
211 if (len > 1023)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 c = str;
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
215
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
216 if (*c == '[') {
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
217 /* Check if str is a valid IPv6 identifier */
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
218 gboolean valid = FALSE;
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
219
27548
f1f901b3d6f2 Save one traversal of the domain for IPv6 validation.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
220 if (*(c + len - 1) != ']')
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
221 return FALSE;
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
222
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
223 /* Ugly, but in-place */
27548
f1f901b3d6f2 Save one traversal of the domain for IPv6 validation.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
224 *(gchar *)(c + len - 1) = '\0';
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
225 valid = purple_ipv6_address_is_valid(c + 1);
27548
f1f901b3d6f2 Save one traversal of the domain for IPv6 validation.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
226 *(gchar *)(c + len - 1) = ']';
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
227
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
228 return valid;
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
229 }
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
230
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 while(c && *c) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 gunichar ch = g_utf8_get_char(c);
27537
7e79102cda40 Be more restrictive in the characters allowed by jabber_nameprep_validate()
Mark Doliner <mark@kingant.net>
parents: 27536
diff changeset
233 /* The list of characters allowed in domain names is pretty small */
27539
167d7c3a4f7b XMPP allows for internationalized domain names.
Paul Aurich <paul@darkrain42.org>
parents: 27538
diff changeset
234 if ((ch <= 0x7F && !( (ch >= 'a' && ch <= 'z')
27537
7e79102cda40 Be more restrictive in the characters allowed by jabber_nameprep_validate()
Mark Doliner <mark@kingant.net>
parents: 27536
diff changeset
235 || (ch >= '0' && ch <= '9')
7e79102cda40 Be more restrictive in the characters allowed by jabber_nameprep_validate()
Mark Doliner <mark@kingant.net>
parents: 27536
diff changeset
236 || (ch >= 'A' && ch <= 'Z')
7e79102cda40 Be more restrictive in the characters allowed by jabber_nameprep_validate()
Mark Doliner <mark@kingant.net>
parents: 27536
diff changeset
237 || ch == '.'
27539
167d7c3a4f7b XMPP allows for internationalized domain names.
Paul Aurich <paul@darkrain42.org>
parents: 27538
diff changeset
238 || ch == '-' )) || (ch >= 0x80 && !g_unichar_isgraph(ch)))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 c = g_utf8_next_char(c);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 gboolean jabber_resourceprep_validate(const char *str)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
249 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
250 gboolean result;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
251 #else
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 const char *c;
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
253 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 if(!str)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 if(strlen(str) > 1023)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
261 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
262 strncpy(idn_buffer, str, sizeof(idn_buffer) - 1);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
263 idn_buffer[sizeof(idn_buffer) - 1] = '\0';
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
264 result = jabber_resourceprep(idn_buffer, sizeof(idn_buffer));
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
265 return result;
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
266 #else /* USE_IDN */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 c = str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 while(c && *c) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 gunichar ch = g_utf8_get_char(c);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 if(!g_unichar_isgraph(ch) && ch != ' ')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 c = g_utf8_next_char(c);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 return TRUE;
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
277 #endif /* USE_IDN */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
280 static JabberID*
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
281 jabber_id_new_internal(const char *str, gboolean allow_terminating_slash)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 {
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
283 const char *at = NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
284 const char *slash = NULL;
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
285 const char *c;
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
286 gboolean needs_validation = FALSE;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
287 #if 0
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
288 gboolean node_is_required = FALSE;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
289 #endif
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
290 #ifndef USE_IDN
26979
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
291 char *node = NULL;
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
292 char *domain;
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
293 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 JabberID *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
296 if (!str)
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
297 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
298
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
299 for (c = str; *c != '\0'; c++)
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
300 {
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
301 switch (*c) {
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
302 case '@':
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
303 if (!slash) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
304 if (at) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
305 /* Multiple @'s in the node/domain portion, not a valid JID! */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
306 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
307 }
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
308 if (c == str) {
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
309 /* JIDs cannot start with @ */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
310 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
311 }
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
312 if (c[1] == '\0') {
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
313 /* JIDs cannot end with @ */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
314 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
315 }
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
316 at = c;
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
317 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
318 break;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
319
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
320 case '/':
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
321 if (!slash) {
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
322 if (c == str) {
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
323 /* JIDs cannot start with / */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
324 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
325 }
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
326 if (c[1] == '\0' && !allow_terminating_slash) {
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
327 /* JIDs cannot end with / */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
328 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
329 }
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
330 slash = c;
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
331 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
332 break;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
333
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
334 default:
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
335 /* characters allowed everywhere */
27536
8f2dfa6ef2f7 Of course, these should be >= and <=
Mark Doliner <mark@kingant.net>
parents: 27532
diff changeset
336 if ((*c >= 'a' && *c <= 'z')
8f2dfa6ef2f7 Of course, these should be >= and <=
Mark Doliner <mark@kingant.net>
parents: 27532
diff changeset
337 || (*c >= '0' && *c <= '9')
8f2dfa6ef2f7 Of course, these should be >= and <=
Mark Doliner <mark@kingant.net>
parents: 27532
diff changeset
338 || (*c >= 'A' && *c <= 'Z')
27532
04d8452dee48 Change jabber_id_new() to iterate byte by byte instead of character
Mark Doliner <mark@kingant.net>
parents: 27530
diff changeset
339 || *c == '.' || *c == '-')
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
340 /* We're good */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
341 break;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
342
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
343 #if 0
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
344 if (slash != NULL) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
345 /* characters allowed only in the resource */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
346 if (implement_me)
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
347 /* We're good */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
348 break;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
349 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
350
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
351 /* characters allowed only in the node */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
352 if (implement_me) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
353 /*
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
354 * Ok, this character is valid, but only if it's a part
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
355 * of the node and not the domain. But we don't know
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
356 * if "c" is a part of the node or the domain until after
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
357 * we've found the @. So set a flag for now and check
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
358 * that we found an @ later.
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
359 */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
360 node_is_required = TRUE;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
361 break;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
362 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
363 #endif
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
364
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
365 /*
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
366 * Hmm, this character is a bit more exotic. Better fall
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
367 * back to using the more expensive UTF-8 compliant
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
368 * stringprep functions.
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
369 */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
370 needs_validation = TRUE;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
371 break;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
372 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
373 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
374
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
375 #if 0
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
376 if (node_is_required && at == NULL)
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
377 /* Found invalid characters in the domain */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
378 return NULL;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
379 #endif
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
380
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
381 if (!needs_validation) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
382 /* JID is made of only ASCII characters--just lowercase and return */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
383 jid = g_new0(JabberID, 1);
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
384
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
385 if (at) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
386 jid->node = g_ascii_strdown(str, at - str);
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
387 if (slash) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
388 jid->domain = g_ascii_strdown(at + 1, slash - (at + 1));
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
389 if (*(slash + 1))
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
390 jid->resource = g_strdup(slash + 1);
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
391 } else {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
392 jid->domain = g_ascii_strdown(at + 1, -1);
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
393 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
394 } else {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
395 if (slash) {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
396 jid->domain = g_ascii_strdown(str, slash - str);
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
397 if (*(slash + 1))
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
398 jid->resource = g_strdup(slash + 1);
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
399 } else {
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
400 jid->domain = g_ascii_strdown(str, -1);
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
401 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
402 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
403 return jid;
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
404 }
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
405
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
406 /*
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
407 * If we get here, there are some non-ASCII chars in the string, so
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
408 * we'll need to validate it, normalize, and finally do a full jabber
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
409 * nodeprep on the jid.
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
410 */
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
411
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
412 if (!g_utf8_validate(str, -1, NULL))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
415 #ifdef USE_IDN
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
416 return jabber_idn_validate(str, at, slash, c /* points to the null */);
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
417 #else /* USE_IDN */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
418
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 jid = g_new0(JabberID, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
421 /* normalization */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 if(at) {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
423 node = g_utf8_casefold(str, at-str);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 if(slash) {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
425 domain = g_utf8_casefold(at+1, slash-(at+1));
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
426 if (*(slash + 1))
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
427 jid->resource = g_utf8_normalize(slash+1, -1, G_NORMALIZE_NFKC);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 } else {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
429 domain = g_utf8_casefold(at+1, -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 if(slash) {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
433 domain = g_utf8_casefold(str, slash-str);
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
434 if (*(slash + 1))
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
435 jid->resource = g_utf8_normalize(slash+1, -1, G_NORMALIZE_NFKC);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 } else {
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
437 domain = g_utf8_casefold(str, -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
26979
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
441 if (node) {
27637
aac25c66a843 For JIDs, do strdown before normalization.
Paul Aurich <paul@darkrain42.org>
parents: 27548
diff changeset
442 jid->node = g_utf8_normalize(node, -1, G_NORMALIZE_NFKC);
26979
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
443 g_free(node);
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
444 }
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
445
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
446 if (domain) {
27637
aac25c66a843 For JIDs, do strdown before normalization.
Paul Aurich <paul@darkrain42.org>
parents: 27548
diff changeset
447 jid->domain = g_utf8_normalize(domain, -1, G_NORMALIZE_NFKC);
26979
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
448 g_free(domain);
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
449 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450
27530
1b580473e753 Check in a version of jabber_id_new() that is hopefully more efficient.
Mark Doliner <mark@kingant.net>
parents: 27507
diff changeset
451 /* and finally the jabber nodeprep */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 if(!jabber_nodeprep_validate(jid->node) ||
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
453 !jabber_domain_validate(jid->domain) ||
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 !jabber_resourceprep_validate(jid->resource)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 return jid;
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
460 #endif /* USE_IDN */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 jabber_id_free(JabberID *jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 if(jid) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 if(jid->node)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 g_free(jid->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 if(jid->domain)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 g_free(jid->domain);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 if(jid->resource)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 g_free(jid->resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 g_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 char *jabber_get_resource(const char *in)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 JabberID *jid = jabber_id_new(in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 char *out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 out = g_strdup(jid->resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 return out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
492 char *
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
493 jabber_get_bare_jid(const char *in)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 JabberID *jid = jabber_id_new(in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 char *out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
498 if (!jid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 return NULL;
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
500 out = jabber_id_get_bare_jid(jid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 return out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
506 char *
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
507 jabber_id_get_bare_jid(const JabberID *jid)
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
508 {
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
509 g_return_val_if_fail(jid != NULL, NULL);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
510
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
511 return g_strconcat(jid->node ? jid->node : "",
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
512 jid->node ? "@" : "",
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
513 jid->domain,
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
514 NULL);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
515 }
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28482
diff changeset
516
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
517 JabberID *
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
518 jabber_id_new(const char *str)
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
519 {
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
520 return jabber_id_new_internal(str, FALSE);
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
521 }
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
522
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
523 const char *jabber_normalize(const PurpleAccount *account, const char *in)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
525 PurpleConnection *gc = account ? account->gc : NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 JabberStream *js = gc ? gc->proto_data : NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 static char buf[3072]; /* maximum legal length of a jabber jid */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 JabberID *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 28405
diff changeset
530 jid = jabber_id_new_internal(in, TRUE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533
26979
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
534 if(js && jid->node && jid->resource &&
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
535 jabber_chat_find(js, jid->node, jid->domain))
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
536 g_snprintf(buf, sizeof(buf), "%s@%s/%s", jid->node, jid->domain,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 jid->resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 else
26979
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
539 g_snprintf(buf, sizeof(buf), "%s%s%s", jid->node ? jid->node : "",
34e4e2ca7db9 jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents: 24641
diff changeset
540 jid->node ? "@" : "", jid->domain);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 return buf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
27023
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
547 gboolean
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
548 jabber_is_own_server(JabberStream *js, const char *str)
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
549 {
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
550 JabberID *jid;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
551 gboolean equal;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
552
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
553 if (str == NULL)
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
554 return FALSE;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
555
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
556 g_return_val_if_fail(*str != '\0', FALSE);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
557
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
558 jid = jabber_id_new(str);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
559 if (!jid)
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
560 return FALSE;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
561
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
562 equal = (jid->node == NULL &&
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
563 g_str_equal(jid->domain, js->user->domain) &&
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
564 jid->resource == NULL);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
565 jabber_id_free(jid);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
566 return equal;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
567 }
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
568
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
569 gboolean
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
570 jabber_is_own_account(JabberStream *js, const char *str)
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
571 {
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
572 JabberID *jid;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
573 gboolean equal;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
574
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
575 if (str == NULL)
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
576 return TRUE;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
577
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
578 g_return_val_if_fail(*str != '\0', FALSE);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
579
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
580 jid = jabber_id_new(str);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
581 if (!jid)
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
582 return FALSE;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
583
27050
fd7dc5cc0310 Allow incoming stanzas to match 'our account' if they come from our resource.
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
584 equal = (purple_strequal(jid->node, js->user->node) &&
27023
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
585 g_str_equal(jid->domain, js->user->domain) &&
27050
fd7dc5cc0310 Allow incoming stanzas to match 'our account' if they come from our resource.
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
586 (jid->resource == NULL ||
fd7dc5cc0310 Allow incoming stanzas to match 'our account' if they come from our resource.
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
587 g_str_equal(jid->resource, js->user->resource)));
27023
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
588 jabber_id_free(jid);
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
589 return equal;
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
590 }
e8795ced8c9b Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents: 26979
diff changeset
591
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
592 PurpleConversation *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
593 jabber_find_unnormalized_conv(const char *name, PurpleAccount *account)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
595 PurpleConversation *c = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 GList *cnv;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 g_return_val_if_fail(name != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
600 for(cnv = purple_get_conversations(); cnv; cnv = cnv->next) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
601 c = (PurpleConversation*)cnv->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
602 if(purple_conversation_get_type(c) == PURPLE_CONV_TYPE_IM &&
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
603 !purple_utf8_strcasecmp(name, purple_conversation_get_name(c)) &&
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
604 account == purple_conversation_get_account(c))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 return c;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610
24641
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
611 /* The same as purple_util_get_image_checksum, but guaranteed to remain SHA1 */
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
612 char *
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
613 jabber_calculate_data_sha1sum(gconstpointer data, size_t len)
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
614 {
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
615 PurpleCipherContext *context;
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
616 static gchar digest[41];
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
617
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
618 context = purple_cipher_context_new_by_name("sha1", NULL);
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
619 if (context == NULL)
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
620 {
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
621 purple_debug_error("jabber", "Could not find sha1 cipher\n");
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
622 g_return_val_if_reached(NULL);
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
623 }
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
624
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
625 /* Hash the data */
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
626 purple_cipher_context_append(context, data, len);
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
627 if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL))
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
628 {
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
629 purple_debug_error("jabber", "Failed to get SHA-1 digest.\n");
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
630 g_return_val_if_reached(NULL);
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
631 }
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
632 purple_cipher_context_destroy(context);
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
633
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
634 return g_strdup(digest);
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
635 }
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 19680
diff changeset
636