comparison mcabber/src/utils.c @ 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 dfd9c62b3a39
children 339e85418b49
comparison
equal deleted inserted replaced
455:9d0e72607251 456:471c9ccde028
264 int domlen; 264 int domlen;
265 265
266 if (!jid) return 1; 266 if (!jid) return 1;
267 267
268 domain = strchr(jid, '@'); 268 domain = strchr(jid, '@');
269 if (!domain) return 1; 269
270 270 /* the username is optional */
271 /* node identifiers may not be longer than 1023 bytes */ 271 if (!domain) {
272 if ((domain == jid) || (domain-jid > 1023)) 272 domain = jid;
273 return 1; 273 } else {
274 domain++; 274 /* node identifiers may not be longer than 1023 bytes */
275 275 if ((domain == jid) || (domain-jid > 1023))
276 /* check for low and invalid ascii characters in the username */
277 for (str = jid; *str != '@'; str++) {
278 if (*str <= 32 || *str == ':' || *str == '@' ||
279 *str == '<' || *str == '>' || *str == '\'' ||
280 *str == '"' || *str == '&') {
281 return 1; 276 return 1;
282 } 277 domain++;
283 } 278
284 279 /* check for low and invalid ascii characters in the username */
285 /* the username is okay as far as we can tell without LIBIDN */ 280 for (str = jid; *str != '@'; str++) {
281 if (*str <= 32 || *str == ':' || *str == '@' ||
282 *str == '<' || *str == '>' || *str == '\'' ||
283 *str == '"' || *str == '&') {
284 return 1;
285 }
286 }
287 /* the username is okay as far as we can tell without LIBIDN */
288 }
286 289
287 resource = strchr(domain, '/'); 290 resource = strchr(domain, '/');
288 291
289 /* the resource is optional */ 292 /* the resource is optional */
290 if (resource) { 293 if (resource) {