From 2737bc4c11c43999b63bb1ec0d89741c060ced45 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Sun, 22 Oct 2017 01:25:16 +0300 Subject: [PATCH] core: remove g_uri_(un)escape_string() replacements As BR is glib >= 2.18.0 we now can assume that g_uri_escape_string() and g_uri_unescape_string() APIs exist, which were introduced in 2.16.0. --- src/core/sipe-domino.c | 40 ++-------------------------------------- src/core/sipe-utils.c | 27 --------------------------- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/core/sipe-domino.c b/src/core/sipe-domino.c index 2cf267eb..00593f5c 100755 --- a/src/core/sipe-domino.c +++ b/src/core/sipe-domino.c @@ -3,7 +3,7 @@ * * pidgin-sipe * - * Copyright (C) 2010-2015 SIPE Project + * Copyright (C) 2010-2017 SIPE Project * Copyright (C) 2010 pier11 * * @@ -388,46 +388,10 @@ static void sipe_domino_process_login_response(SIPE_UNUSED_PARAMETER struct sipe static gchar *sipe_domino_uri_escape(const gchar *string) { - gchar *escaped; - if (!string) return(NULL); if (!g_utf8_validate(string, -1, NULL)) return(NULL); -#if GLIB_CHECK_VERSION(2,16,0) - escaped = g_uri_escape_string(string, NULL, FALSE); -#else - /* loosely based on libpurple/util.c:purple_url_encode() */ - { - GString *buf = g_string_new(NULL); - - while (*string) { - gunichar c = g_utf8_get_char(string); - - /* If the character is an ASCII character and is alphanumeric - * no need to escape */ - if (c < 128 && - (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~')) { - g_string_append_c(buf, c); - } else { - gchar *p, utf_char[6]; - guint bytes = g_unichar_to_utf8(c, utf_char); - - p = utf_char; - while (bytes-- > 0) { - g_string_append_printf(buf, - "%%%02X", - *p++ & 0xff); - } - } - - string = g_utf8_next_char(string); - } - - escaped = g_string_free(buf, FALSE); - } -#endif - - return(escaped); + return(g_uri_escape_string(string, NULL, FALSE)); } static void diff --git a/src/core/sipe-utils.c b/src/core/sipe-utils.c index 8c46618d..25e1ec5a 100644 --- a/src/core/sipe-utils.c +++ b/src/core/sipe-utils.c @@ -564,34 +564,7 @@ sipe_utils_uri_unescape(const gchar *string) if (!string) return NULL; -#if GLIB_CHECK_VERSION(2,16,0) unescaped = g_uri_unescape_string(string, NULL); -#else - // based on libpurple/util.c:purple_url_decode() - { - GString *buf = g_string_new(NULL); - size_t len = strlen(string); - char hex[3]; - - hex[2] = '\0'; - - while (len--) { - gchar c = *string++; - - if ((len >= 2) && (c == '%')) { - strncpy(hex, string, 2); - c = strtol(hex, NULL, 16); - - string += 2; - len -= 2; - } - - g_string_append_c(buf, c); - } - - unescaped = g_string_free(buf, FALSE); - } -#endif if (unescaped && !g_utf8_validate(unescaped, -1, (const gchar **)&tmp)) *tmp = '\0'; -- 2.11.4.GIT