]> git.pld-linux.org Git - packages/pidgin.git/blob - gaim-0.75.patch
- rel2
[packages/pidgin.git] / gaim-0.75.patch
1 *** src/protocols/yahoo/yahoo.c.orig    Thu Jan 22 09:57:03 2004
2 --- src/protocols/yahoo/yahoo.c Thu Jan 22 10:15:11 2004
3 ***************
4 *** 20,25 ****
5 --- 20,26 ----
6    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
7    *
8    */
9 + #include <limits.h>
10   #include "internal.h"
11   
12   #include "account.h"
13 ***************
14 *** 131,138 ****
15 --- 132,146 ----
16                 while (pos + 1 < len) {
17                         if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
18                                 break;
19 +                       if (x >= sizeof(key)-1) {
20 +                               x++; pos++;
21 +                               continue;
22
23 +                       }
24                         key[x++] = data[pos++];
25                 }
26 +               if (x >= sizeof(key)-1)
27 +                       x = 0;
28                 key[x] = 0;
29                 pos += 2;
30                 pair->key = strtol(key, NULL, 10);
31 ***************
32 *** 868,899 ****
33         }
34   }
35   
36   #define OUT_CHARSET "utf-8"
37   
38   static char *yahoo_decode(const char *text)
39   {
40         char *converted;
41 !       char *p, *n, *new;
42 !       
43 !       n = new = g_malloc(strlen (text) + 1);
44
45 !       for (p = (char *)text; *p; p++, n++) {
46                 if (*p == '\\') {
47 !                       sscanf(p + 1, "%3o\n", (int *)n);
48 !                       p += 3;
49 !               }
50 !               else
51 !                       *n = *p;
52         }
53
54         *n = '\0';
55 -       
56         converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
57         g_free(new);
58   
59         return converted;
60   }
61   
62   static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
63   {
64         GaimAccount *account = gaim_connection_get_account(gc);
65 --- 876,941 ----
66         }
67   }
68   
69
70 + static void octal(const char **p, const char *end, unsigned char *n)
71 + {
72 +       int i, c;
73
74 +       for (i = 0, c = 0; i < 3 && *p < end; ++i, ++*p) {
75 +               c <<= 3;
76 +               switch (**p) {
77 +               case '0': break;
78 +               case '1': c += 1; break;
79 +               case '2': c += 2; break;
80 +               case '3': c += 3; break;
81 +               case '4': c += 4; break;
82 +               case '5': c += 5; break;
83 +               case '6': c += 6; break;
84 +               case '7': c += 7; break;
85 +               default:
86 +                         if (i == 0) {
87 +                                 *n = **p;
88 +                                 ++*p;
89 +                                 return;
90 +                         }
91 +                         c >>= 3;
92 +                         goto done;
93 +               }
94 +       }
95 + done:
96 +       *n = (c > UCHAR_MAX) ? '?' : c;
97 +       return;
98 + }
99
100   #define OUT_CHARSET "utf-8"
101   
102   static char *yahoo_decode(const char *text)
103   {
104         char *converted;
105 !       unsigned char *n, *new;
106 !       size_t len;
107 !       const char *p, *end;
108
109 !       len = strlen (text);
110 !       p = text;
111 !       end = &text[len];
112 !       n = new = g_malloc(len + 1);
113 !       while (p < end) {
114                 if (*p == '\\') {
115 !                       ++p;
116 !                       octal(&p, end, n);
117 !               } else
118 !                       *n = *p++;
119 !               ++n;
120         }
121         *n = '\0';
122         converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
123         g_free(new);
124   
125         return converted;
126   }
127   
128
129   static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
130   {
131         GaimAccount *account = gaim_connection_get_account(gc);
132 ***************
133 *** 1903,1934 ****
134   
135   static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond)
136   {
137         GaimConnection *gc = data;
138         GaimAccount *account = gaim_connection_get_account(gc);
139         struct yahoo_data *yd = gc->proto_data;
140 !       char buf[1024], buf2[256], *i = buf, *r = buf2;
141 !       int len, o = 0;
142   
143         len = read(source, buf, sizeof(buf));
144 !       if (len <= 0  || strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302"))) {
145                 gaim_connection_error(gc, _("Unable to read"));
146                 return;
147         }
148 !       
149 !       while ((i = strstr(i, "Set-Cookie: ")) && 0 < 2) {
150 !               i += strlen("Set-Cookie: "); 
151 !               for (;*i != ';'; r++, i++) {
152 !                       *r = *i;
153 !               }
154 !               *r=';';
155 !               r++;
156 !               *r=' ';
157 !               r++;
158 !               o++;
159 !       }
160 !       /* Get rid of that "; " */
161 !       *(r-2) = '\0';
162 !       yd->auth = g_strdup(buf2);
163         gaim_input_remove(gc->inpa);
164         close(source);
165         /* Now we have our cookies to login with.  I'll go get the milk. */
166 --- 1945,1974 ----
167   
168   static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond)
169   {
170 +       static const char http302[] = "HTTP/1.0 302";
171 +       static const char setcookie[] = "Set-Cookie: ";
172         GaimConnection *gc = data;
173         GaimAccount *account = gaim_connection_get_account(gc);
174         struct yahoo_data *yd = gc->proto_data;
175 !       char buf[1024], *i = buf;
176 !       int len;
177 !       GString *s;
178   
179         len = read(source, buf, sizeof(buf));
180 !       if (len <= 0 || (len >= sizeof(http302)-1 &&
181 !           memcmp(http302, buf, sizeof(http302)-1) != 0)) {
182                 gaim_connection_error(gc, _("Unable to read"));
183                 return;
184         }
185 !       s = g_string_sized_new(len);
186 !       buf[len] = '\0';
187 !       while ((i = strstr(i, setcookie)) != NULL) {
188 !               i += sizeof(setcookie)-1;
189 !               for (;*i != ';'; i++)
190 !                       g_string_append_c(s, *i);
191 !               g_string_append(s, "; ");
192 !       }
193 !       yd->auth = g_string_free(s, FALSE);
194         gaim_input_remove(gc->inpa);
195         close(source);
196         /* Now we have our cookies to login with.  I'll go get the milk. */
197 ***************
198 *** 1974,1988 ****
199         const char *c = buf;
200         char *d;
201         char name[64], value[64];
202         while ((c < (buf + len)) && (c = strstr(c, "<input "))) {
203                 c = strstr(c, "name=\"") + strlen("name=\"");
204 !               for (d = name; *c!='"'; c++, d++) 
205                         *d = *c;
206                 *d = '\0';
207                 d = strstr(c, "value=\"") + strlen("value=\"");
208                 if (strchr(c, '>') < d)
209                         break;
210 !               for (c = d, d = value; *c!='"'; c++, d++)
211                         *d = *c;
212                 *d = '\0';
213                 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
214 --- 2014,2030 ----
215         const char *c = buf;
216         char *d;
217         char name[64], value[64];
218 +       int count = sizeof(name)-1;
219         while ((c < (buf + len)) && (c = strstr(c, "<input "))) {
220                 c = strstr(c, "name=\"") + strlen("name=\"");
221 !               for (d = name; *c!='"' && count; c++, d++, count--)
222                         *d = *c;
223                 *d = '\0';
224 +               count = sizeof(value)-1;
225                 d = strstr(c, "value=\"") + strlen("value=\"");
226                 if (strchr(c, '>') < d)
227                         break;
228 !               for (c = d, d = value; *c!='"' && count; c++, d++, count--)
229                         *d = *c;
230                 *d = '\0';
231                 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
232 *** src/proxy.c.orig    Thu Jan 22 08:27:26 2004
233 --- src/proxy.c Thu Jan 22 08:28:05 2004
234 ***************
235 *** 974,980 ****
236   
237         gaim_input_remove(phb->inpa);
238   
239 !       while ((nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
240                 if (inputline[pos - 1] == '\n')
241                         nlc++;
242                 else if (inputline[pos - 1] != '\r')
243 --- 974,980 ----
244   
245         gaim_input_remove(phb->inpa);
246   
247 !       while ((pos < sizeof(inputline)-1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
248                 if (inputline[pos - 1] == '\n')
249                         nlc++;
250                 else if (inputline[pos - 1] != '\r')
251 *** src/util.c.orig     Fri Jan  9 22:04:56 2004
252 --- src/util.c  Thu Jan 22 08:26:14 2004
253 ***************
254 *** 247,270 ****
255   /**************************************************************************
256    * Quoted Printable Functions
257    **************************************************************************/
258 ! void
259 ! gaim_quotedp_decode(const char *str, char **ret_str, int *ret_len)
260   {
261 !       char *p, *n, *new;
262   
263 !       n = new = g_malloc(strlen (str) + 1);
264   
265 !       for (p = (char *)str; *p; p++, n++) {
266                 if (*p == '=') {
267 !                       sscanf(p + 1, "%2x\n", (int *)n);
268 !                       p += 2;
269 !               }
270 !               else if (*p == '_')
271                         *n = ' ';
272                 else
273                         *n = *p;
274         }
275
276         *n = '\0';
277   
278         if (ret_len)
279 --- 247,317 ----
280   /**************************************************************************
281    * Quoted Printable Functions
282    **************************************************************************/
283 ! static void hex(const char **p, const char *end, unsigned char *n)
284   {
285 !       int i, c;
286   
287 !       for (i = 0, c = 0; i < 2 && *p < end; ++i, ++*p) {
288 !               c <<= 4;
289 !               switch (**p) {
290 !               case '0': break;
291 !               case '1': c += 1; break;
292 !               case '2': c += 2; break;
293 !               case '3': c += 3; break;
294 !               case '4': c += 4; break;
295 !               case '5': c += 5; break;
296 !               case '6': c += 6; break;
297 !               case '7': c += 7; break;
298 !               case '8': c += 8; break;
299 !               case '9': c += 9; break;
300 !               case 'a': c += 10; break;
301 !               case 'b': c += 11; break;
302 !               case 'c': c += 12; break;
303 !               case 'd': c += 13; break;
304 !               case 'e': c += 14; break;
305 !               case 'f': c += 15; break;
306 !               case 'A': c += 10; break;
307 !               case 'B': c += 11; break;
308 !               case 'C': c += 12; break;
309 !               case 'D': c += 13; break;
310 !               case 'E': c += 14; break;
311 !               case 'F': c += 15; break;
312 !               default:
313 !                         if (i == 0) {
314 !                                 *n = **p;
315 !                                 ++*p;
316 !                                 return;
317 !                         }
318 !                         c >>= 4;
319 !                         goto done;
320 !               }
321 !       }
322 ! done:
323 !       *n = (c > UCHAR_MAX) ? '?' : c;
324 !       return;
325 ! }
326   
327 ! void
328 ! gaim_quotedp_decode(const char *str, char **ret_str, int *ret_len)
329 ! {
330 !       const char *p, *end;
331 !       unsigned char *n, *new;
332 !       size_t len;
333
334 !       len = strlen (str);
335 !       n = new = g_malloc(len + 1);
336 !       p = str;
337 !       end = &p[len];
338 !       while (p < end) {
339                 if (*p == '=') {
340 !                       ++p;
341 !                       hex(&p, end, n);
342 !               } else if (*p == '_')
343                         *n = ' ';
344                 else
345                         *n = *p;
346 +               ++n;
347         }
348         *n = '\0';
349   
350         if (ret_len)
351 ***************
352 *** 1962,1968 ****
353                            char **ret_path)
354   {
355         char scan_info[255];
356 !       char port_str[5];
357         int f;
358         const char *turl;
359         char host[256], path[256];
360 --- 2009,2015 ----
361                            char **ret_path)
362   {
363         char scan_info[255];
364 !       char port_str[6];
365         int f;
366         const char *turl;
367         char host[256], path[256];
368 ***************
369 *** 1982,1997 ****
370         }
371   
372         g_snprintf(scan_info, sizeof(scan_info),
373 !                          "%%[%s]:%%[%s]/%%[%s]", addr_ctrl, port_ctrl, page_ctrl);
374   
375         f = sscanf(url, scan_info, host, port_str, path);
376   
377         if (f == 1)
378         {
379                 g_snprintf(scan_info, sizeof(scan_info),
380 !                                  "%%[%s]/%%[%s]",
381                                    addr_ctrl, page_ctrl);
382                 f = sscanf(url, scan_info, host, path);
383                 g_snprintf(port_str, sizeof(port_str), "80");
384         }
385   
386 --- 2029,2049 ----
387         }
388   
389         g_snprintf(scan_info, sizeof(scan_info),
390 !                          "%%255[%s]:%%5[%s]/%%255[%s]", addr_ctrl, port_ctrl, page_ctrl);
391 !       addr_ctrl[sizeof(addr_ctrl)-1] = '\0';
392 !       port_ctrl[sizeof(port_ctrl)-1] = '\0';
393 !       page_ctrl[sizeof(page_ctrl)-1] = '\0';
394   
395         f = sscanf(url, scan_info, host, port_str, path);
396   
397         if (f == 1)
398         {
399                 g_snprintf(scan_info, sizeof(scan_info),
400 !                                  "%%255[%s]/%%255[%s]",
401                                    addr_ctrl, page_ctrl);
402                 f = sscanf(url, scan_info, host, path);
403 +               addr_ctrl[sizeof(addr_ctrl)-1] = '\0';
404 +               page_ctrl[sizeof(page_ctrl)-1] = '\0';
405                 g_snprintf(port_str, sizeof(port_str), "80");
406         }
407   
408 ***************
409 *** 2081,2089 ****
410   static size_t
411   parse_content_len(const char *data, size_t data_len)
412   {
413 !       size_t content_len = 0;
414   
415 !       sscanf(data, "Content-Length: %d", (int *)&content_len);
416   
417         return content_len;
418   }
419 --- 2133,2146 ----
420   static size_t
421   parse_content_len(const char *data, size_t data_len)
422   {
423 !       int content_len = 0;
424 !       char *tmp;
425   
426 !       tmp = g_malloc(data_len + 1);
427 !       memcpy(tmp, data, data_len);
428 !       tmp[data_len] = '\0';
429 !       sscanf(tmp, "Content-Length: %d", &content_len);
430 !       g_free(tmp);
431   
432         return content_len;
433   }
This page took 0.056575 seconds and 3 git commands to generate.