X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fvcard.c;h=50675cc5353585a46753973b1f89e12e1e72eee6;hb=c477d6a73cf3afdc47913e2c775ceb5938b6a469;hp=1f866250118501e22e422c70a9882011df74bb32;hpb=26a4a07bdacdaa7013bf45cc235df207708acfde;p=citadel.git diff --git a/webcit/vcard.c b/webcit/vcard.c index 1f8662501..50675cc53 100644 --- a/webcit/vcard.c +++ b/webcit/vcard.c @@ -48,9 +48,11 @@ void remove_charset_attribute(char *strbuf) remove_token(strbuf, i, ';'); } } - if (strlen(strbuf) > 0) { - if (strbuf[strlen(strbuf)-1] == ';') { - strbuf[strlen(strbuf)-1] = 0; + if (!IsEmptyStr(strbuf)) { + int len; + len = strlen(strbuf); + if (strbuf[len-1] == ';') { + strbuf[len-1] = 0; } } } @@ -84,6 +86,7 @@ struct vCard *vcard_load(char *vtext) { char *mycopy, *ptr; char *namebuf, *valuebuf; int i; + int len; int colonpos, nlpos; if (vtext == NULL) return vcard_new(); @@ -95,12 +98,15 @@ struct vCard *vcard_load(char *vtext) { * To make it easier to parse, we convert CRLF to LF, and unfold any * multi-line fields into single lines. */ - for (i=0; i0) { + while (*ptr != '\0') { colonpos = (-1); nlpos = (-1); colonpos = pattern2(ptr, ":"); @@ -147,7 +153,7 @@ struct vCard *vcard_load(char *vtext) { } - while ( (*ptr != '\n') && (strlen(ptr)>0) ) { + while ( (*ptr != '\n') && (*ptr != '\0') ) { ++ptr; } if (*ptr == '\n') ++ptr; @@ -176,13 +182,15 @@ char *vcard_get_prop(struct vCard *v, char *propname, int is_partial, int instance, int get_propname) { int i; int found_instance = 0; + int len; + len = strlen(propname); if (v->numprops) for (i=0; i<(v->numprops); ++i) { if ( (!strcasecmp(v->prop[i].name, propname)) || (propname[0] == 0) || ( (!strncasecmp(v->prop[i].name, - propname, strlen(propname))) - && (v->prop[i].name[strlen(propname)] == ';') + propname, len)) + && (v->prop[i].name[len] == ';') && (is_partial) ) ) { if (instance == found_instance++) { if (get_propname) { @@ -260,7 +268,7 @@ void vcard_set_prop(struct vCard *v, char *name, char *value, int append) { /** - * \brief Serialize a struct vcard into a standard text/x-vcard MIME type. + * \brief Serialize a struct vcard into its standard format. * \param v vCard to serialize * \return the serialized vCard */