pidgin: c1255f13: I accidentally checked this in as 4fcb92...

markdoliner at pidgin.im markdoliner at pidgin.im
Wed Jul 8 16:50:27 EDT 2009


-----------------------------------------------------------------
Revision: c1255f13669cb83fbbc4662d713fcd20a639f4ad
Ancestor: 8cd17139719734afe4de1e3393885e491e2cf52e
Author: markdoliner at pidgin.im
Date: 2009-07-08T20:47:08
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c1255f13669cb83fbbc4662d713fcd20a639f4ad

Modified files:
        libpurple/protocols/jabber/jutil.c libpurple/server.c

ChangeLog: 

I accidentally checked this in as 4fcb9258ad826a7ff163b0f374e70b4b556ef25c

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jutil.c	2bfbca92715a1c75c94ed703a7ff01499a4a7789
+++ libpurple/protocols/jabber/jutil.c	912799b76983833354a4420afc830bbb9b370f21
@@ -103,86 +103,20 @@ jabber_id_new(const char *str)
 JabberID*
 jabber_id_new(const char *str)
 {
-	const char *at = NULL;
-	const char *slash = NULL;
-	const char *c;
-	gboolean needs_validation = FALSE;
+	char *at;
+	char *slash;
 	char *node = NULL;
 	char *domain;
 	JabberID *jid;
 
-	if (!str)
+	if(!str || !g_utf8_validate(str, -1, NULL))
 		return NULL;
 
-	for (c = str; *c != '\0'; c++) {
-		switch (*c) {
-			case '@':
-				if (!slash) {
-					if (at) {
-						/* Multiple @'s in the node/domain portion, not a valid JID! */
-						return NULL;
-					}
-					at = c;
-				}
-				break;
-
-			case '/':
-				if (!slash)
-					slash = c;
-				break;
-
-			default:
-				/* make sure this character falls within the allowed ascii characters
-				 * specified in the nodeprep RFC.  If it's outside of this range,
-				 * the character is probably unicode and will be validated using the
-				 * more expensive UTF-8 compliant nodeprep functions
-				 */
-				if ( !(	('a' <= *c && *c <= '~') ||  /*a-z{|}~*/
-						('.' <= *c && *c <= '9') ||  /*./0123456789*/
-						('A' <= *c && *c <= '_') ||  /*A-Z[\]^_*/
-						(*c == ';')  ))              /*;*/
-				{
-					needs_validation = TRUE;
-				}
-				break;
-		}
-	}
-
-	if (!needs_validation) {
-		/* JID is made of only ASCII characters--just lowercase and return */
-		jid = g_new0(JabberID, 1);
-
-		if (at) {
-			jid->node = g_ascii_strdown(str, at - str);
-			if (slash) {
-				jid->domain = g_ascii_strdown(at + 1, slash - (at + 1));
-				jid->resource = g_strdup(slash + 1);
-			} else {
-				jid->domain = g_ascii_strdown(at + 1, -1);
-			}
-		} else {
-			if (slash) {
-				jid->domain = g_ascii_strdown(str, slash - str);
-				jid->resource = g_strdup(slash + 1);
-			} else {
-				jid->domain = g_ascii_strdown(str, -1);
-			}
-		}
-		return jid;
-	}
-
-	/*
-	 * If we get here, there are some non-ASCII chars in the string, so
-	 * we'll need to validate it, normalize, and finally do a full jabber
-	 * nodeprep on the jid.
-	 */
-
-	if (!g_utf8_validate(str, -1, NULL))
-		return NULL;
-
 	jid = g_new0(JabberID, 1);
 
-	/* normalization */
+	at = g_utf8_strchr(str, -1, '@');
+	slash = g_utf8_strchr(str, -1, '/');
+
 	if(at) {
 		node = g_utf8_normalize(str, at-str, G_NORMALIZE_NFKC);
 		if(slash) {
@@ -210,7 +144,6 @@ jabber_id_new(const char *str)
 		g_free(domain);
 	}
 
-	/* and finally the jabber nodeprep */
 	if(!jabber_nodeprep_validate(jid->node) ||
 			!jabber_nameprep_validate(jid->domain) ||
 			!jabber_resourceprep_validate(jid->resource)) {
============================================================
--- libpurple/server.c	2575dbcc3ca722651a05796798edc8923025168a
+++ libpurple/server.c	8730c7801e191207259746e59cbe9f4618e20f6b
@@ -592,10 +592,13 @@ void serv_got_im(PurpleConnection *gc, c
 	 */
 	flags |= PURPLE_MESSAGE_RECV;
 
-	if (!purple_privacy_check(account, who)) {
-		purple_signal_emit(purple_conversations_get_handle(), "blocked-im-msg",
-				account, who, msg, flags, (unsigned int)mtime);
-		return;
+	if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->set_permit_deny == NULL) {
+		/* protocol does not support privacy, handle it ourselves */
+		if (!purple_privacy_check(account, who)) {
+			purple_signal_emit(purple_conversations_get_handle(), "blocked-im-msg",
+					account, who, msg, flags, (unsigned int)mtime);
+			return;
+		}
 	}
 
 	/*


More information about the Commits mailing list