Rev 4364 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4364 | Rev 5043 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | #include |
25 | #include |
26 | #include |
26 | #include |
Line 27... | Line 27... | ||
27 | 27 | ||
Line -... | Line 28... | ||
- | 28 | #include |
|
- | 29 | ||
28 | #include |
30 | #include "http.h" |
Line 29... | Line 31... | ||
29 | 31 | ||
30 | #include |
32 | #include |
31 | 33 | ||
Line 200... | Line 202... | ||
200 | 202 | ||
201 | /* we URL unescape the data first, just incase some insane page |
203 | /* we URL unescape the data first, just incase some insane page |
202 | * decides to nest URL and base64 encoding. Like, say, Acid2. |
204 | * decides to nest URL and base64 encoding. Like, say, Acid2. |
203 | */ |
205 | */ |
- | 206 | templen = c->datalen; |
|
204 | templen = c->datalen; |
207 | /* TODO: Replace unescaped = line with http.obj */ |
- | 208 | /* unescaped = curl_easy_unescape(curl, comma + 1, 0, &templen); */ |
|
- | 209 | LOG(("Calling http_unescape_url in data.c\n")); |
|
- | 210 | unescaped = http_unescape_url(comma + 1); |
|
- | 211 | c->datalen = strlen(unescaped); |
|
205 | unescaped = curl_easy_unescape(curl, comma + 1, 0, &templen); |
212 | |
- | 213 | /* c->datalen = templen; */ |
|
206 | c->datalen = templen; |
214 | |
207 | if (unescaped == NULL) { |
215 | if (unescaped == NULL) { |
208 | msg.type = FETCH_ERROR; |
216 | msg.type = FETCH_ERROR; |
209 | msg.data.error = "Unable to URL decode data: URL"; |
217 | msg.data.error = "Unable to URL decode data: URL"; |
210 | fetch_data_send_callback(&msg, c); |
218 | fetch_data_send_callback(&msg, c); |
Line 216... | Line 224... | ||
216 | if (base64_decode(unescaped, c->datalen, c->data, |
224 | if (base64_decode(unescaped, c->datalen, c->data, |
217 | &(c->datalen)) == false) { |
225 | &(c->datalen)) == false) { |
218 | msg.type = FETCH_ERROR; |
226 | msg.type = FETCH_ERROR; |
219 | msg.data.error = "Unable to Base64 decode data: URL"; |
227 | msg.data.error = "Unable to Base64 decode data: URL"; |
220 | fetch_data_send_callback(&msg, c); |
228 | fetch_data_send_callback(&msg, c); |
221 | curl_free(unescaped); |
229 | /* curl_free(unescaped); */ |
- | 230 | free(unescaped); |
|
222 | return false; |
231 | return false; |
223 | } |
232 | } |
224 | } else { |
233 | } else { |
225 | c->data = malloc(c->datalen); |
234 | c->data = malloc(c->datalen); |
226 | if (c->data == NULL) { |
235 | if (c->data == NULL) { |
227 | msg.type = FETCH_ERROR; |
236 | msg.type = FETCH_ERROR; |
228 | msg.data.error = |
237 | msg.data.error = |
229 | "Unable to allocate memory for data: URL"; |
238 | "Unable to allocate memory for data: URL"; |
230 | fetch_data_send_callback(&msg, c); |
239 | fetch_data_send_callback(&msg, c); |
231 | curl_free(unescaped); |
240 | /* curl_free(unescaped); */ |
- | 241 | free(unescaped); |
|
232 | return false; |
242 | return false; |
233 | } |
243 | } |
234 | memcpy(c->data, unescaped, c->datalen); |
244 | memcpy(c->data, unescaped, c->datalen); |
235 | } |
245 | } |
Line 236... | Line 246... | ||
236 | 246 | ||
- | 247 | /* curl_free(unescaped); */ |
|
Line 237... | Line 248... | ||
237 | curl_free(unescaped); |
248 | free(unescaped); |
238 | 249 | ||
Line 239... | Line 250... | ||
239 | return true; |
250 | return true; |