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

xml_add_ns: try a different namespace prefix, if the current one is in use #5003

Merged
Merged
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
12 changes: 6 additions & 6 deletions cassandane/tiny-tests/Caldav/calendar_setcolor
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ EOF

my $propfindXml = <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<D:propfind xmlns:D="DAV:" xmlns:A="http://apple.com/ns/ical/">
<D:prop>
<A:calendar-color/>
</D:prop>
</D:propfind>
<propfind xmlns="DAV:">
<prop>
<calendar-color xmlns="http://apple.com/ns/ical/"/>
</prop>
</propfind>
EOF

# Assert that color isn't set.
Expand All @@ -42,7 +42,7 @@ EOF
$response = $CalDAV->Request('PROPPATCH', "/dav/calendars/user/cassandane/". $CalendarId,
$proppatchXml, 'Content-Type' => 'text/xml');

# Assert color ist set.
# Assert color is set.
$response = $CalDAV->Request('PROPFIND', "/dav/calendars/user/cassandane/". $CalendarId,
$propfindXml, 'Content-Type' => 'text/xml');
$propstat = $response->{'{DAV:}response'}[0]{'{DAV:}propstat'}[0];
Expand Down
10 changes: 8 additions & 2 deletions imap/http_dav.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,14 @@ static int xml_add_ns(xmlNodePtr req, xmlNsPtr *respNs, xmlNodePtr root)
ensure_ns(respNs, NS_JMAPCAL, root,
(const char *) nsDef->href,
(const char *) nsDef->prefix);
else
xmlNewNs(root, nsDef->href, nsDef->prefix);
else if (!xmlNewNs(root, nsDef->href, nsDef->prefix)) {
/* namespace prefix already in use */
char myprefix[20];
snprintf(myprefix, sizeof(myprefix), "X%X", strhash((const char *) nsDef->href) & 0xffff);
xmlFree((char *) nsDef->prefix);
nsDef->prefix = xmlStrdup(BAD_CAST myprefix);
xmlNewNs(root, nsDef->href, BAD_CAST myprefix); // could again return NULL
}
}
}

Expand Down