audio: uploaded patches for third party libs
[siplcs.git] / contrib / media-patches / purple_mime_document_parsen.patch
blobf7bdee80efae50278f4156197278449d1a49125a
1 --- workspace/pidgin/libpurple/mime.c 2010-03-27 20:11:19.456986210 +0100
2 +++ src/pidgin-2.6.5/libpurple/mime.c 2010-03-28 15:56:46.300983807 +0200
3 @@ -436,6 +436,43 @@
4 g_free(bnd);
7 +static char *
8 +parse_boundary(const char* ct)
9 +{
10 + const char BOUNDARY[] = "boundary=";
11 + char *boundary_begin = g_strrstr(ct, BOUNDARY);
12 + char *boundary_end;
13 + gboolean has_quotes = FALSE;
15 + if (!boundary_begin)
16 + return NULL;
18 + boundary_begin += sizeof(BOUNDARY) - 1;
20 + if (*boundary_begin == '"') {
21 + has_quotes = TRUE;
22 + ++boundary_begin;
23 + }
25 + if (has_quotes)
26 + boundary_end = strchr(boundary_begin, '"');
27 + else {
28 + boundary_end = strchr(boundary_begin, ' ');
29 + if (!boundary_end) {
30 + boundary_end = strchr(boundary_begin, ';');
31 + if (!boundary_end)
32 + boundary_end = boundary_begin + strlen(boundary_begin);
33 + }
34 + }
36 + if (!boundary_end)
37 + return NULL;
39 + char *bnd = g_malloc0(boundary_end - boundary_begin + 1);
40 + memcpy(bnd, boundary_begin, boundary_end - boundary_begin);
42 + return bnd;
45 PurpleMimeDocument *
46 purple_mime_document_parsen(const char *buf, gsize len)
47 @@ -457,9 +494,10 @@
49 const char *ct = fields_get(&doc->fields, "content-type");
50 if(ct && purple_str_has_prefix(ct, "multipart")) {
51 - char *bd = strrchr(ct, '=');
52 - if(bd++) {
53 + char *bd = parse_boundary(ct);
54 + if(bd) {
55 doc_parts_load(doc, bd, b, n);
56 + g_free(bd);