Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: iTIP with URL (percent) encoded addresses #5048

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion imap/calsched_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ EXPORTED void get_schedule_addresses(const char *mboxname,
for (i = 0; i < strarray_size(&caluseraddr.uris); i++) {
const char *item = strarray_nth(&caluseraddr.uris, i);
if (!strncasecmp(item, "mailto:", 7)) item += 7;
strarray_add(addresses, item);

char *addr = xmlURIUnescapeString(item, strlen(item), NULL);
strarray_addm(addresses, addr);
}
}
else if (strchr(userid, '@')) {
Expand Down
14 changes: 14 additions & 0 deletions imap/ical_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <string.h>
#include <sysexits.h>
#include <syslog.h>
#include <libxml/uri.h>

#include "assert.h"
#include "bsearch.h"
Expand Down Expand Up @@ -1184,6 +1185,19 @@ EXPORTED const char *icalproperty_get_invitee(icalproperty *prop)
return recip;
}

EXPORTED char *icalproperty_get_decoded_participant(icalproperty *prop)
{
const char *addr;

if (icalproperty_isa(prop) == ICAL_ORGANIZER_PROPERTY)
addr = icalproperty_get_organizer(prop);
else
addr = icalproperty_get_attendee(prop);

if (!strncasecmp(addr, "mailto:", 7)) addr += 7;

return xmlURIUnescapeString(addr, strlen(addr), NULL);
}

EXPORTED icaltimetype
icalcomponent_get_recurrenceid_with_zone(icalcomponent *comp)
Expand Down
1 change: 1 addition & 0 deletions imap/ical_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ extern void icalcomponent_remove_invitee(icalcomponent *comp,
extern icalproperty *icalcomponent_get_first_invitee(icalcomponent *comp);
extern icalproperty *icalcomponent_get_next_invitee(icalcomponent *comp);
extern const char *icalproperty_get_invitee(icalproperty *prop);
extern char *icalproperty_get_decoded_participant(icalproperty *prop);

extern icaltimetype icalcomponent_get_recurrenceid_with_zone(icalcomponent *c);

Expand Down
4 changes: 2 additions & 2 deletions imap/jmap_calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -4148,9 +4148,8 @@ static int setcalendarevents_schedule(const char *sched_userid,
icalcomponent_get_first_property(comp, ICAL_ORGANIZER_PROPERTY);
if (!prop) goto done;

const char *organizer = icalproperty_get_organizer(prop);
char *organizer = icalproperty_get_decoded_participant(prop);
if (!organizer) goto done;
if (!strncasecmp(organizer, "mailto:", 7)) organizer += 7;
if (organizer &&
/* XXX Hack for Outlook */ icalcomponent_get_first_invitee(comp)) {

Expand Down Expand Up @@ -4182,6 +4181,7 @@ static int setcalendarevents_schedule(const char *sched_userid,
oldical, newical, SCHED_MECH_JMAP_SET);
}
}
free(organizer);

done:
if (oldical) icalcomponent_free(oldical);
Expand Down
8 changes: 7 additions & 1 deletion lib/strarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,15 @@ EXPORTED void strarray_cat(strarray_t *dest, const strarray_t *src)
}

EXPORTED int strarray_add(strarray_t *sa, const char *s)
{
return strarray_addm(sa, xstrdupnull(s));
}

EXPORTED int strarray_addm(strarray_t *sa, char *s)
{
int pos = strarray_find(sa, s, 0);
if (pos < 0) pos = strarray_append(sa, s);
if (pos < 0) pos = strarray_appendm(sa, s);
else free(s);
return pos;
}

Expand Down
1 change: 1 addition & 0 deletions lib/strarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void strarray_free(strarray_t *);

int strarray_append(strarray_t *, const char *);
int strarray_add(strarray_t *, const char *);
int strarray_addm(strarray_t *sa, char *s);
int strarray_add_case(strarray_t *, const char *);
int strarray_appendm(strarray_t *, char *);
void strarray_set(strarray_t *, int idx, const char *);
Expand Down