comparison mcabber/src/utils.c @ 1641:c3c7d6d0348f

Remove (probably) unnecessary check The string is valid is the prep profile can be applied, AIUI.
author Mikael Berthe <mikael@lilotux.net>
date Sun, 25 Oct 2009 23:53:54 +0100
parents bf2258e29834
children
comparison
equal deleted inserted replaced
1640:bf2258e29834 1641:c3c7d6d0348f
408 { 408 {
409 const char *str; 409 const char *str;
410 const char *domain, *resource; 410 const char *domain, *resource;
411 int domlen; 411 int domlen;
412 #ifdef HAVE_LIBIDN 412 #ifdef HAVE_LIBIDN
413 char *idnpp, *ascidnp; 413 char *idnpp;
414 int r; 414 int r;
415 #endif 415 #endif
416 416
417 if (!fjid) return 1; 417 if (!fjid) return 1;
418 418
435 *idnpp = 0; 435 *idnpp = 0;
436 436
437 r = stringprep(idnprep, 1023, 0, stringprep_xmpp_nodeprep); 437 r = stringprep(idnprep, 1023, 0, stringprep_xmpp_nodeprep);
438 if (r != STRINGPREP_OK || !idnprep[0]) 438 if (r != STRINGPREP_OK || !idnprep[0])
439 return 1; 439 return 1;
440
441 // check the string hasn't been modified, in which case we consider
442 // it's a failure (as fjid is read-only)
443 idnpp = idnprep;
444 str = fjid;
445 while (*idnpp) {
446 if (*idnpp++ != *str++)
447 return 1;
448 }
449 /* the username looks okay */ 440 /* the username looks okay */
450 #else 441 #else
451 /* check for low and invalid ascii characters in the username */ 442 /* check for low and invalid ascii characters in the username */
452 for (str = fjid; *str != JID_DOMAIN_SEPARATOR; str++) { 443 for (str = fjid; *str != JID_DOMAIN_SEPARATOR; str++) {
453 if (*str <= ' ' || *str == ':' || *str == JID_DOMAIN_SEPARATOR || 444 if (*str <= ' ' || *str == ':' || *str == JID_DOMAIN_SEPARATOR ||
494 485
495 r = stringprep_nameprep(idnprep, 1023); 486 r = stringprep_nameprep(idnprep, 1023);
496 if (r != STRINGPREP_OK || !idnprep[0]) 487 if (r != STRINGPREP_OK || !idnprep[0])
497 return 1; 488 return 1;
498 489
499 if (idna_to_ascii_8z(idnprep, &ascidnp, IDNA_USE_STD3_ASCII_RULES) != 490 if (idna_to_ascii_8z(idnprep, &idnpp, IDNA_USE_STD3_ASCII_RULES) !=
500 IDNA_SUCCESS) 491 IDNA_SUCCESS)
501 return 1; 492 return 1;
502 else 493 else
503 free(ascidnp); 494 free(idnpp);
504
505 // check the string hasn't been modified, in which case we consider
506 // it's a failure (as fjid is read-only)
507 idnpp = idnprep;
508 str = domain;
509 while (*idnpp) {
510 if (*idnpp++ != *str++)
511 return 1;
512 }
513 #else 495 #else
514 /* make sure the hostname is valid characters */ 496 /* make sure the hostname is valid characters */
515 for (str = domain; *str != '\0' && *str != JID_RESOURCE_SEPARATOR; str++) { 497 for (str = domain; *str != '\0' && *str != JID_RESOURCE_SEPARATOR; str++) {
516 if (!(isalnum(*str) || *str == '.' || *str == '-' || *str == '_')) 498 if (!(isalnum(*str) || *str == '.' || *str == '-' || *str == '_'))
517 return 1; 499 return 1;