changeset 456:471c9ccde028

Make username optional in check_jid_syntax() This allows sending message/status to a Jabber agent, for example.
author Mikael Berthe <mikael@lilotux.net>
date Tue, 27 Sep 2005 19:52:29 +0200
parents 9d0e72607251
children 2fd528c49173
files mcabber/src/utils.c
diffstat 1 files changed, 16 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/utils.c	Mon Sep 26 22:45:10 2005 +0200
+++ b/mcabber/src/utils.c	Tue Sep 27 19:52:29 2005 +0200
@@ -266,24 +266,27 @@
   if (!jid) return 1;
 
   domain = strchr(jid, '@');
-  if (!domain) return 1;
 
-  /* node identifiers may not be longer than 1023 bytes */
-  if ((domain == jid) || (domain-jid > 1023))
-    return 1;
-  domain++;
+  /* the username is optional */
+  if (!domain) {
+    domain = jid;
+  } else {
+    /* node identifiers may not be longer than 1023 bytes */
+    if ((domain == jid) || (domain-jid > 1023))
+      return 1;
+    domain++;
 
-  /* check for low and invalid ascii characters in the username */
-  for (str = jid; *str != '@'; str++) {
-    if (*str <= 32 || *str == ':' || *str == '@' ||
-        *str == '<' || *str == '>' || *str == '\'' ||
-        *str == '"' || *str == '&') {
-      return 1;
+    /* check for low and invalid ascii characters in the username */
+    for (str = jid; *str != '@'; str++) {
+      if (*str <= 32 || *str == ':' || *str == '@' ||
+              *str == '<' || *str == '>' || *str == '\'' ||
+              *str == '"' || *str == '&') {
+        return 1;
+      }
     }
+    /* the username is okay as far as we can tell without LIBIDN */
   }
 
-  /* the username is okay as far as we can tell without LIBIDN */
-
   resource = strchr(domain, '/');
 
   /* the resource is optional */