From: Ethan B. <ebl...@us...> - 2004-01-22 02:44:16
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv20856/src Modified Files: util.c util.h Log Message: IRC quoting for HTML entities by Daniel Atallah Index: util.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/util.c,v retrieving revision 1.266 retrieving revision 1.267 diff -u -d -p -r1.266 -r1.267 --- util.c 16 Jan 2004 17:13:20 -0000 1.266 +++ util.c 22 Jan 2004 02:44:13 -0000 1.267 @@ -1317,6 +1317,39 @@ gaim_markup_linkify(const char *text) return tmp; } +char * +gaim_escape_html(const char *html) { + char *escaped = NULL; + + if (html != NULL) { + const char *c = html; + GString *ret = g_string_new(""); + while (*c) { + switch(*c) { + case '&': + ret = g_string_append(ret, "&"); + break; + case '<': + ret = g_string_append(ret, "<"); + break; + case '>': + ret = g_string_append(ret, ">"); + break; + case '"': + ret = g_string_append(ret, """); + break; + default: + ret = g_string_append_c(ret, *c); + } + c++; + } + + escaped = ret->str; + g_string_free(ret, FALSE); + } + return escaped; + +} /************************************************************************** * Path/Filename Functions Index: util.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/util.h,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -p -r1.41 -r1.42 --- util.h 10 Jan 2004 04:04:56 -0000 1.41 +++ util.h 22 Jan 2004 02:44:13 -0000 1.42 @@ -266,6 +266,16 @@ char *gaim_markup_strip_html(const char */ char *gaim_markup_linkify(const char *str); +/** + * Escapes HTML special characters to be displayed literally. + * For example '&' is replaced by "&" and so on + * + * @param html The string in which to escape any HTML special characters + * + * @return the text with HTML special characters escaped + */ +char *gaim_escape_html(const char *html); + /*@}*/ |