Changeset 5d56a27 for zephyr.c


Ignore:
Timestamp:
Mar 24, 2011, 4:55:03 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
4e29ecb
Parents:
3f52e14
Message:
Handle edge cases correctly in long_zuser and short_zuser

foo@bar@REALM and foo@ were not correctly parsed. (The former should be
foo@bar [at] REALM and the latter is implicitly foo [at] DEFAULT-REALM.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    re5da3fe r5d56a27  
    11671167char *short_zuser(const char *in)
    11681168{
    1169   char *out, *ptr;
    1170 
    1171   out=g_strdup(in);
    1172   ptr=strchr(out, '@');
    1173   if (ptr) {
    1174     if (!strcasecmp(ptr+1, owl_zephyr_get_realm())) {
    1175       *ptr='\0';
    1176     }
    1177   }
    1178   return(out);
     1169  char *ptr = strrchr(in, '@');
     1170  if (ptr && (ptr[1] == '\0' || !strcasecmp(ptr+1, owl_zephyr_get_realm()))) {
     1171    return g_strndup(in, ptr - in);
     1172  }
     1173  return g_strdup(in);
    11791174}
    11801175
     
    11841179char *long_zuser(const char *in)
    11851180{
    1186   if (strchr(in, '@')) {
    1187     return(g_strdup(in));
    1188   }
    1189   return(g_strdup_printf("%s@%s", in, owl_zephyr_get_realm()));
     1181  char *ptr = strrchr(in, '@');
     1182  if (ptr) {
     1183    if (ptr[1])
     1184      return g_strdup(in);
     1185    /* Ends in @, so assume default realm. */
     1186    return g_strdup_printf("%s%s", in, owl_zephyr_get_realm());
     1187  }
     1188  return g_strdup_printf("%s@%s", in, owl_zephyr_get_realm());
    11901189}
    11911190
Note: See TracChangeset for help on using the changeset viewer.