comparison src/gtkimhtml.c @ 8334:0d1e5870d328

[gaim-migrate @ 9058] you can now use :/ as a smiley safely thanks to Nathan Owens. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 25 Feb 2004 21:26:58 +0000
parents 6f549c1d0829
children f1ca7e06e8de
comparison
equal deleted inserted replaced
8333:85dbaac926a7 8334:0d1e5870d328
1313 val = ret->str; 1313 val = ret->str;
1314 g_string_free(ret, FALSE); 1314 g_string_free(ret, FALSE);
1315 return val; 1315 return val;
1316 } 1316 }
1317 1317
1318 static const char *accepted_protocols[] = {
1319 "http://",
1320 "https://",
1321 "ftp://"
1322 };
1323
1324 static const int accepted_protocols_size = 3;
1325
1326 /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so
1327 the caller knows how long the protocol string is. */
1328 int gtk_imhtml_is_protocol(const char *text)
1329 {
1330 gint i;
1331
1332 for(i=0; i<accepted_protocols_size; i++){
1333 if( strncasecmp(text, accepted_protocols[i], strlen(accepted_protocols[i])) == 0 ){
1334 return strlen(accepted_protocols[i]);
1335 }
1336 }
1337 return 0;
1338 }
1339
1318 GString* gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, 1340 GString* gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml,
1319 const gchar *text, 1341 const gchar *text,
1320 GtkIMHtmlOptions options, 1342 GtkIMHtmlOptions options,
1321 GSList *images) 1343 GSList *images)
1322 { 1344 {
1334 gint len; 1356 gint len;
1335 gint tlen, smilelen, wpos=0; 1357 gint tlen, smilelen, wpos=0;
1336 gint type; 1358 gint type;
1337 const gchar *c; 1359 const gchar *c;
1338 gchar *amp; 1360 gchar *amp;
1361 gint len_protocol;
1339 1362
1340 guint bold = 0, 1363 guint bold = 0,
1341 italics = 0, 1364 italics = 0,
1342 underline = 0, 1365 underline = 0,
1343 strike = 0, 1366 strike = 0,
1869 wpos = 0; 1892 wpos = 0;
1870 /* NEW_BIT (NEW_TEXT_BIT); */ 1893 /* NEW_BIT (NEW_TEXT_BIT); */
1871 } 1894 }
1872 c++; 1895 c++;
1873 pos++; 1896 pos++;
1897 } else if ((len_protocol = gtk_imhtml_is_protocol(c)) > 0){
1898 while(len_protocol--){
1899 /* Skip the next len_protocol characters, but make sure they're
1900 copied into the ws array.
1901 */
1902 ws [wpos++] = *c++;
1903 pos++;
1904 }
1874 } else if (imhtml->show_smileys && (gtk_imhtml_is_smiley (imhtml, fonts, c, &smilelen) || gtk_imhtml_is_smiley(imhtml, NULL, c, &smilelen))) { 1905 } else if (imhtml->show_smileys && (gtk_imhtml_is_smiley (imhtml, fonts, c, &smilelen) || gtk_imhtml_is_smiley(imhtml, NULL, c, &smilelen))) {
1875 GtkIMHtmlFontDetail *fd; 1906 GtkIMHtmlFontDetail *fd;
1876 1907
1877 gchar *sml = NULL; 1908 gchar *sml = NULL;
1878 if (fonts) { 1909 if (fonts) {