From: Luke S. <lsc...@us...> - 2004-09-11 15:38:41
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32443/src Modified Files: Tag: oldstatus gtkimhtml.c Log Message: (11:37:38) datallah: LSchiere: http://www.butfer.com/gaim-patches/win32_html_clipboard_dos2unix_and_robustness.patch (there was a guy in #wingaim complaining about this a few days ago and i've too) (11:38:09) LSchiere: patching file ChangeLog.win32 (11:38:09) LSchiere: Hunk #1 FAILED at 1. (11:38:20) datallah: LSchiere: that is on the branch (11:38:24) LSchiere: ah Index: gtkimhtml.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkimhtml.c,v retrieving revision 1.364 retrieving revision 1.364.2.1 diff -u -d -p -r1.364 -r1.364.2.1 --- gtkimhtml.c 31 Aug 2004 20:10:21 -0000 1.364 +++ gtkimhtml.c 11 Sep 2004 15:38:32 -0000 1.364.2.1 @@ -151,9 +151,11 @@ static gchar * clipboard_win32_to_html(char *clipboard) { const char *header; const char *begin, *end; - gint start=0; - gint finish=0; + gint start = 0; + gint finish = 0; gchar *html; + gchar **split; + int clipboard_length = 0; #if 0 /* Debugging for Windows clipboard */ FILE *fd; @@ -165,25 +167,38 @@ clipboard_win32_to_html(char *clipboard) fclose(fd); #endif - if (!(header = strstr(clipboard, "StartFragment:"))) - return NULL; + clipboard_length = strlen(clipboard); + if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) + return NULL; sscanf(header, "StartFragment:%d", &start); - header = strstr(clipboard, "EndFragment:"); + if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) + return NULL; sscanf(header, "EndFragment:%d", &finish); + if (finish > clipboard_length) + finish = clipboard_length; + + if (start > finish) + start = finish; + begin = clipboard + start; - if (header == NULL) - end = clipboard + strlen(clipboard); - else - end = clipboard + finish; + end = clipboard + finish; - html = g_strstrip(g_strndup(begin, end-begin)); + html = g_strndup(begin, end - begin); + + /* any newlines in the string will now be \r\n, so we need to strip out the \r */ + split = g_strsplit(html, "\r\n", 0); + g_free(html); + html = g_strjoinv("\n", split); + g_strfreev(split); + + html = g_strstrip(html); #if 0 /* Debugging for Windows clipboard */ - gaim_debug_info("imhtml clipboard", "HTML fragment: %s\n", html); + gaim_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); #endif return html; |