Mercurial > pidgin.yaz
comparison libpurple/util.c @ 26854:ab31daf1c1ee
Sadrul pointed me at g_markup_escape_text, thanks!
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 02 May 2009 04:02:53 +0000 |
parents | e72df47d41fe |
children | 795606e2f7c6 8290e36a5a73 e4ab3d5362df cfa78428d8b2 |
comparison
equal
deleted
inserted
replaced
26853:e72df47d41fe | 26854:ab31daf1c1ee |
---|---|
2355 } | 2355 } |
2356 return g_string_free(ret, FALSE); | 2356 return g_string_free(ret, FALSE); |
2357 } | 2357 } |
2358 | 2358 |
2359 char * | 2359 char * |
2360 purple_escape_html(const char *str) | |
2361 { | |
2362 GString *ret; | |
2363 const char *in = str; | |
2364 | |
2365 if (str == NULL) | |
2366 return NULL; | |
2367 | |
2368 ret = g_string_sized_new(strlen(str)); | |
2369 for ( ; *in; ++in) { | |
2370 switch (*in) { | |
2371 case '&': | |
2372 ret = g_string_append_len(ret, "&", 5); | |
2373 break; | |
2374 case '"': | |
2375 ret = g_string_append_len(ret, """, 6); | |
2376 break; | |
2377 case '<': | |
2378 ret = g_string_append_len(ret, "<", 4); | |
2379 break; | |
2380 case '>': | |
2381 ret = g_string_append_len(ret, ">", 4); | |
2382 break; | |
2383 default: | |
2384 ret = g_string_append_c(ret, *in); | |
2385 break; | |
2386 } | |
2387 } | |
2388 | |
2389 return g_string_free(ret, FALSE); | |
2390 } | |
2391 | |
2392 char * | |
2393 purple_unescape_html(const char *html) { | 2360 purple_unescape_html(const char *html) { |
2394 if (html != NULL) { | 2361 if (html != NULL) { |
2395 const char *c = html; | 2362 const char *c = html; |
2396 GString *ret = g_string_new(""); | 2363 GString *ret = g_string_new(""); |
2397 while (*c) { | 2364 while (*c) { |