annotate dpi/datauri.c @ 2104:3e7e5395f0bc

non-ASCII keybindings Alexander Voigt has kindly done some testing, and it seems that this makes bindings to most keys on a German keyboard possible -- except those that need AltGr don't work yet.
author corvid <corvid@lavabit.com>
date Thu, 23 Jun 2011 19:24:11 +0000
parents da16ca154e64
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * File: datauri.c
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
35
d9e7b35430de Updated copyright lines
jcid
parents: 0
diff changeset
4 * Copyright (C) 2006-2007 Jorge Arellano Cid <jcid@dillo.org>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 * Filter dpi for the "data:" URI scheme (RFC 2397).
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 * the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11 * (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 #include <unistd.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include <stdio.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 #include <stdlib.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 #include <string.h>
1305
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
18 #include <ctype.h>
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
19 #include <errno.h>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 #include "../dpip/dpip.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 #include "dpiutil.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 * Debugging macros
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 */
488
66fda00f15d2 Set debug macro MSG var in datauri and https dpis (controlled by SILENT define)
Jorge Arellano Cid <jcid@dillo.org>
parents: 368
diff changeset
27 #define SILENT 1
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #define _MSG(...)
488
66fda00f15d2 Set debug macro MSG var in datauri and https dpis (controlled by SILENT define)
Jorge Arellano Cid <jcid@dillo.org>
parents: 368
diff changeset
29 #if SILENT
66fda00f15d2 Set debug macro MSG var in datauri and https dpis (controlled by SILENT define)
Jorge Arellano Cid <jcid@dillo.org>
parents: 368
diff changeset
30 #define MSG(...)
66fda00f15d2 Set debug macro MSG var in datauri and https dpis (controlled by SILENT define)
Jorge Arellano Cid <jcid@dillo.org>
parents: 368
diff changeset
31 #else
66fda00f15d2 Set debug macro MSG var in datauri and https dpis (controlled by SILENT define)
Jorge Arellano Cid <jcid@dillo.org>
parents: 368
diff changeset
32 #define MSG(...) fprintf(stderr, "[datauri dpi]: " __VA_ARGS__)
66fda00f15d2 Set debug macro MSG var in datauri and https dpis (controlled by SILENT define)
Jorge Arellano Cid <jcid@dillo.org>
parents: 368
diff changeset
33 #endif
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 * Global variables
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
38 static Dsh *sh = NULL;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39
1305
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
40 static void b64strip_illegal_chars(unsigned char* str)
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
41 {
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
42 unsigned char *p, *s = str;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43
1305
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
44 MSG("len=%d{%s}\n", strlen((char*)str), str);
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
45
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
46 for (p = s; (*p = *s); ++s) {
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
47 if (isalnum(*p) || strchr("+/=", *p))
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
48 ++p;
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
49 }
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
50
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
51 MSG("len=%d{%s}\n", strlen((char *)str), str);
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
52 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
54 static int b64decode(unsigned char* str)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 {
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
56 unsigned char *cur, *start;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
57 int d, dlast, phase;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
58 unsigned char c;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
59 static int table[256] = {
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
60 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
61 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
62 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
63 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
64 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
65 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
66 -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
67 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
68 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
69 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
70 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
71 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
72 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
73 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
74 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
75 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
76 };
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
78 d = dlast = phase = 0;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
79 start = str;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
80 for (cur = str; *cur != '\0'; ++cur ) {
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
81 // jer: treat line endings as physical breaks.
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
82 //if (*cur == '\n' || *cur == '\r'){phase = dlast = 0; continue;}
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
83 d = table[(int)*cur];
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
84 if (d != -1) {
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
85 switch(phase) {
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
86 case 0:
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
87 ++phase;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
88 break;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
89 case 1:
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
90 c = ((dlast << 2) | ((d & 0x30) >> 4));
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
91 *str++ = c;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
92 ++phase;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
93 break;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
94 case 2:
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
95 c = (((dlast & 0xf) << 4) | ((d & 0x3c) >> 2));
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
96 *str++ = c;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
97 ++phase;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
98 break;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
99 case 3:
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
100 c = (((dlast & 0x03 ) << 6) | d);
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
101 *str++ = c;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
102 phase = 0;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
103 break;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
104 }
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
105 dlast = d;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
106 }
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
107 }
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
108 *str = '\0';
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
109 return str - start;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
110 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
111
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
112 /* Modified from src/url.c --------------------------------------------------*/
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
113
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
114 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
115 * Given an hex octet (e.g., e3, 2F, 20), return the corresponding
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
116 * character if the octet is valid, and -1 otherwise
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
117 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
118 static int Url_decode_hex_octet(const char *s)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
119 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
120 int hex_value;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
121 char *tail, hex[3];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
122
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
123 if (s && (hex[0] = s[0]) && (hex[1] = s[1])) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
124 hex[2] = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
125 hex_value = strtol(hex, &tail, 16);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
126 if (tail - hex == 2)
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 488
diff changeset
127 return hex_value;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
128 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
129 return -1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
130 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
131
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
132 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
133 * Parse possible hexadecimal octets in the URI path.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
134 * Returns a new allocated string.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
135 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
136 char *a_Url_decode_hex_str(const char *str, size_t *p_sz)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
137 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
138 char *new_str, *dest;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
139 int i, val;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
140
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
141 if (!str) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
142 *p_sz = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
143 return NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
144 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
145
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
146 dest = new_str = dNew(char, strlen(str) + 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
147 for (i = 0; str[i]; i++) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
148 *dest++ = (str[i] == '%' && (val = Url_decode_hex_octet(str+i+1)) >= 0) ?
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
149 i+=2, val : str[i];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
150 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
151 *dest = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
152
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
153 new_str = dRealloc(new_str, sizeof(char) * (dest - new_str + 1));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
154 *p_sz = (size_t)(dest - new_str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
155 return new_str;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
156 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
157
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
158 /* end ----------------------------------------------------------------------*/
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
159
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
160 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
161 * Send decoded data to dillo in an HTTP envelope.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
162 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
163 static void send_decoded_data(const char *url, const char *mime_type,
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
164 unsigned char *data, size_t data_sz)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
165 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
166 char *d_cmd;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
167
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
168 /* Send dpip tag */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
169 d_cmd = a_Dpip_build_cmd("cmd=%s url=%s", "start_send_page", url);
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
170 a_Dpip_dsh_write_str(sh, 1, d_cmd);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
171 dFree(d_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
172
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
173 /* Send HTTP header. */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
174 a_Dpip_dsh_write_str(sh, 0, "Content-type: ");
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
175 a_Dpip_dsh_write_str(sh, 0, mime_type);
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
176 a_Dpip_dsh_write_str(sh, 1, "\n\n");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
177
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
178 /* Send message */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
179 a_Dpip_dsh_write(sh, 0, (char *)data, data_sz);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
180 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
181
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
182 static void send_failure_message(const char *url, const char *mime_type,
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
183 unsigned char *data, size_t data_sz)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
184 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
185 char *d_cmd;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
186 char buf[1024];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
187
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
188 const char *msg =
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
189 "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
190 "<html><body>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
191 "<hr><h1>Datauri dpi</h1><hr>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
192 "<p><b>Can't parse datauri:</b><br>\n";
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
193 const char *msg_mime_type="text/html";
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
194
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
195 /* Send dpip tag */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
196 d_cmd = a_Dpip_build_cmd("cmd=%s url=%s", "start_send_page", url);
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
197 a_Dpip_dsh_write_str(sh, 1, d_cmd);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
198 dFree(d_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
199
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
200 /* Send HTTP header. */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
201 a_Dpip_dsh_write_str(sh, 0, "Content-type: ");
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
202 a_Dpip_dsh_write_str(sh, 0, msg_mime_type);
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
203 a_Dpip_dsh_write_str(sh, 1, "\n\n");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
204
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
205 /* Send message */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
206 a_Dpip_dsh_write_str(sh, 0, msg);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
207
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
208 /* send some debug info */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
209 snprintf(buf, 1024, "mime_type: %s<br>data size: %d<br>data: %s<br>",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
210 mime_type, (int)data_sz, data);
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
211 a_Dpip_dsh_write_str(sh, 0, buf);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
212
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
213 /* close page */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
214 a_Dpip_dsh_write_str(sh, 0, "</body></html>");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
215 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
216
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
217 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
218 * Get mime type from the data URI.
368
2242da885677 - s/todo:/TODO:/g
jcid
parents: 306
diff changeset
219 * TODO: there's no point in handling "charset" because current dillo
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
220 * only handles ISO-LATIN-1. The FLTK2 version (utf-8) could use it in the
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
221 * future.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
222 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
223 static char *datauri_get_mime(char *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
224 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
225 char buf[256];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
226 char *mime_type = NULL, *p;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
227 size_t len = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
228
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
229 if (dStrncasecmp(url, "data:", 5) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
230 if ((p = strchr(url, ',')) && p - url < 256) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
231 url += 5;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
232 len = p - url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
233 strncpy(buf, url, len);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
234 buf[len] = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
235 /* strip ";base64" */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
236 if (len >= 7 && dStrcasecmp(buf + len - 7, ";base64") == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
237 len -= 7;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
238 buf[len] = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
239 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
240 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
241
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
242 /* that's it, now handle omitted types */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
243 if (len == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
244 mime_type = dStrdup("text/plain;charset=US-ASCII");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
245 } else if (!dStrncasecmp(buf, "charset", 7)) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
246 mime_type = dStrconcat("text/plain", buf, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
247 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
248 mime_type = dStrdup(buf);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
249 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
250 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
251
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
252 return mime_type;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
253 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
254
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
255 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
256 * Return a decoded data string.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
257 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 35
diff changeset
258 static unsigned char *datauri_get_data(char *url, size_t *p_sz)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
259 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
260 char *p;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
261 int is_base64 = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
262 unsigned char *data = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
263
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
264 if ((p = strchr(url, ',')) && p - url >= 12 && /* "data:;base64" */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
265 dStrncasecmp(p - 7, ";base64", 7) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
266 is_base64 = 1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
267 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
268
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
269 if (p) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
270 ++p;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
271 if (is_base64) {
1305
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
272 data = (unsigned char *)Unescape_uri_str(p);
29b4740d571e Fixed URL unescaping in the datauri DPI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
273 b64strip_illegal_chars(data);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
274 *p_sz = (size_t) b64decode(data);
168
291457f05a9d - Reverted the datauri patch.
jcid
parents: 164
diff changeset
275 } else {
291457f05a9d - Reverted the datauri patch.
jcid
parents: 164
diff changeset
276 data = (unsigned char *)a_Url_decode_hex_str(p, p_sz);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
277 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
278 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
279 data = (unsigned char *)dStrdup("");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
280 *p_sz = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
281 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
282
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
283 return data;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
284 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
285
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
286 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
287 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
288 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
289 int main(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
290 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
291 char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *mime_type;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
292 unsigned char *data;
1200
6bdf6ea2637a Removed compiler warnings for unused return values
Michal Nowak newman.x@gmail.com
parents: 928
diff changeset
293 int rc;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
294 size_t data_size = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
295
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
296 /* Initialize the SockHandler */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
297 sh = a_Dpip_dsh_new(STDIN_FILENO, STDOUT_FILENO, 8*1024);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
298
1200
6bdf6ea2637a Removed compiler warnings for unused return values
Michal Nowak newman.x@gmail.com
parents: 928
diff changeset
299 rc = chdir("/tmp");
6bdf6ea2637a Removed compiler warnings for unused return values
Michal Nowak newman.x@gmail.com
parents: 928
diff changeset
300 if (rc == -1) {
6bdf6ea2637a Removed compiler warnings for unused return values
Michal Nowak newman.x@gmail.com
parents: 928
diff changeset
301 MSG("paths: error changing directory to /tmp: %s\n",
6bdf6ea2637a Removed compiler warnings for unused return values
Michal Nowak newman.x@gmail.com
parents: 928
diff changeset
302 dStrerror(errno));
6bdf6ea2637a Removed compiler warnings for unused return values
Michal Nowak newman.x@gmail.com
parents: 928
diff changeset
303 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
304
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
305 /* Authenticate our client... */
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
306 if (!(dpip_tag = a_Dpip_dsh_read_token(sh, 1)) ||
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
307 a_Dpip_check_auth(dpip_tag) < 0) {
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
308 MSG("can't authenticate request: %s\n", dStrerror(errno));
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
309 a_Dpip_dsh_close(sh);
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
310 return 1;
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
311 }
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
312 dFree(dpip_tag);
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
313
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
314 /* Read the dpi command from STDIN */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
315 dpip_tag = a_Dpip_dsh_read_token(sh, 1);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
316 MSG("[%s]\n", dpip_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
317
1236
b912173aecd1 Added a_Dpip_get_attr_l() to DPIP's API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1200
diff changeset
318 cmd = a_Dpip_get_attr(dpip_tag, "cmd");
b912173aecd1 Added a_Dpip_get_attr_l() to DPIP's API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1200
diff changeset
319 url = a_Dpip_get_attr(dpip_tag, "url");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
320 if (!cmd || !url) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
321 MSG("Error, cmd=%s, url=%s\n", cmd, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
322 exit (EXIT_FAILURE);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
323 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
324
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
325 /* Parse the data URI */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
326 mime_type = datauri_get_mime(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
327 data = datauri_get_data(url, &data_size);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
328
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
329 MSG("mime_type: %s\n", mime_type);
306
7a76f872ce73 - Eliminated gcc 4.2.3 warnings on 64bit OS.
jcid
parents: 168
diff changeset
330 MSG("data_size: %d\n", (int)data_size);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
331 MSG("data: {%s}\n", data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
332
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
333 if (mime_type && data) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
334 /* good URI */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
335 send_decoded_data(url, mime_type, data, data_size);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
336 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
337 /* malformed URI */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
338 send_failure_message(url, mime_type, data, data_size);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
339 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
340
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
341 dFree(data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
342 dFree(mime_type);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
343 dFree(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
344 dFree(cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
345 dFree(dpip_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
346
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
347 /* Finish the SockHandler */
1395
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
348 a_Dpip_dsh_close(sh);
da16ca154e64 datauri dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1305
diff changeset
349 a_Dpip_dsh_free(sh);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
350
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
351 return 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
352 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
353