# HG changeset patch # User Gary Kramlich # Date 1580481783 21600 # Node ID 35b4a6224d6d97b2b7e22a8420ac9c0d1431ba6c # Parent 8066acc5ed9306c5a53da8f66f50fb5cf38782c7 make libidn a required dependency diff -r 8066acc5ed93 -r 35b4a6224d6d libpurple/protocols/jabber/jutil.c --- a/libpurple/protocols/jabber/jutil.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/protocols/jabber/jutil.c Fri Jan 31 08:43:03 2020 -0600 @@ -32,13 +32,10 @@ #include "presence.h" #include "jutil.h" -#ifdef USE_IDN #include #include static char idn_buffer[1024]; -#endif -#ifdef USE_IDN static gboolean jabber_nodeprep(char *str, size_t buflen) { return stringprep_xmpp_nodeprep(str, buflen) == STRINGPREP_OK; @@ -169,15 +166,9 @@ return jid; } -#endif /* USE_IDN */ - gboolean jabber_nodeprep_validate(const char *str) { -#ifdef USE_IDN gboolean result; -#else - const char *c; -#endif if(!str) return TRUE; @@ -185,24 +176,10 @@ if(strlen(str) > 1023) return FALSE; -#ifdef USE_IDN strncpy(idn_buffer, str, sizeof(idn_buffer) - 1); idn_buffer[sizeof(idn_buffer) - 1] = '\0'; result = jabber_nodeprep(idn_buffer, sizeof(idn_buffer)); return result; -#else /* USE_IDN */ - c = str; - while(c && *c) { - gunichar ch = g_utf8_get_char(c); - if(ch == '\"' || ch == '&' || ch == '\'' || ch == '/' || ch == ':' || - ch == '<' || ch == '>' || ch == '@' || !g_unichar_isgraph(ch)) { - return FALSE; - } - c = g_utf8_next_char(c); - } - - return TRUE; -#endif /* USE_IDN */ } gboolean jabber_domain_validate(const char *str) @@ -258,11 +235,7 @@ gboolean jabber_resourceprep_validate(const char *str) { -#ifdef USE_IDN gboolean result; -#else - const char *c; -#endif if(!str) return TRUE; @@ -270,28 +243,14 @@ if(strlen(str) > 1023) return FALSE; -#ifdef USE_IDN strncpy(idn_buffer, str, sizeof(idn_buffer) - 1); idn_buffer[sizeof(idn_buffer) - 1] = '\0'; result = jabber_resourceprep(idn_buffer, sizeof(idn_buffer)); return result; -#else /* USE_IDN */ - c = str; - while(c && *c) { - gunichar ch = g_utf8_get_char(c); - if(!g_unichar_isgraph(ch) && ch != ' ') - return FALSE; - - c = g_utf8_next_char(c); - } - - return TRUE; -#endif /* USE_IDN */ } char *jabber_saslprep(const char *in) { -#ifdef USE_IDN char *out; g_return_val_if_fail(in != NULL, NULL); @@ -309,22 +268,6 @@ out = g_strdup(idn_buffer); memset(idn_buffer, 0, sizeof(idn_buffer)); return out; -#else /* USE_IDN */ - /* TODO: Something better than disallowing all non-ASCII characters */ - /* TODO: Is this even correct? */ - const guchar *c; - - c = (const guchar *)in; - for ( ; *c; ++c) { - if (*c > 0x7f || /* Non-ASCII characters */ - *c == 0x7f || /* ASCII Delete character */ - (*c < 0x20 && *c != '\t' && *c != '\n' && *c != '\r')) - /* ASCII control characters */ - return NULL; - } - - return g_strdup(in); -#endif /* USE_IDN */ } static JabberID* @@ -334,10 +277,6 @@ const char *slash = NULL; const char *c; gboolean needs_validation = FALSE; -#ifndef USE_IDN - char *node = NULL; - char *domain; -#endif JabberID *jid; if (!str) @@ -431,52 +370,7 @@ if (!g_utf8_validate(str, -1, NULL)) return NULL; -#ifdef USE_IDN return jabber_idn_validate(str, at, slash, c /* points to the null */); -#else /* USE_IDN */ - - jid = g_new0(JabberID, 1); - - /* normalization */ - if(at) { - node = g_utf8_casefold(str, at-str); - if(slash) { - domain = g_utf8_casefold(at+1, slash-(at+1)); - if (*(slash + 1)) - jid->resource = g_utf8_normalize(slash+1, -1, G_NORMALIZE_NFKC); - } else { - domain = g_utf8_casefold(at+1, -1); - } - } else { - if(slash) { - domain = g_utf8_casefold(str, slash-str); - if (*(slash + 1)) - jid->resource = g_utf8_normalize(slash+1, -1, G_NORMALIZE_NFKC); - } else { - domain = g_utf8_casefold(str, -1); - } - } - - if (node) { - jid->node = g_utf8_normalize(node, -1, G_NORMALIZE_NFKC); - g_free(node); - } - - if (domain) { - jid->domain = g_utf8_normalize(domain, -1, G_NORMALIZE_NFKC); - g_free(domain); - } - - /* and finally the jabber nodeprep */ - if(!jabber_nodeprep_validate(jid->node) || - !jabber_domain_validate(jid->domain) || - !jabber_resourceprep_validate(jid->resource)) { - jabber_id_free(jid); - return NULL; - } - - return jid; -#endif /* USE_IDN */ } void diff -r 8066acc5ed93 -r 35b4a6224d6d libpurple/protocols/jabber/meson.build --- a/libpurple/protocols/jabber/meson.build Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/protocols/jabber/meson.build Fri Jan 31 08:43:03 2020 -0600 @@ -2,13 +2,6 @@ # Check for Internationalized Domain Name support ####################################################################### -idn = dependency('libidn', version : '>= 0.0.0', required : get_option('idn')) -if idn.found() - use_idn = [ '-DUSE_IDN' ] -else - use_idn = [] -endif - JABBERSOURCES = [ 'adhoccommands.c', 'adhoccommands.h', @@ -115,7 +108,6 @@ if DYNAMIC_JABBER jabber_prpl = shared_library('jabber', JABBERSOURCES, - c_args : use_idn, link_args : jabber_link_args, dependencies : [gstreamer, idn, libxml, sasl, libpurple_dep, libsoup, glib, gio, math, ws2_32], install : true, install_dir : PURPLE_PLUGINDIR) diff -r 8066acc5ed93 -r 35b4a6224d6d meson.build --- a/meson.build Mon Dec 30 07:08:44 2019 +0000 +++ b/meson.build Fri Jan 31 08:43:03 2020 -0600 @@ -349,6 +349,12 @@ endif ####################################################################### +# Check for libidn (required) +####################################################################### + +idn = dependency('libidn', version : '>= 0.0.0') + +####################################################################### # Check for JSON-GLib (required) ####################################################################### @@ -796,7 +802,6 @@ message('') message('Build with GStreamer support.. : ' + gstreamer.found().to_string()) message('Build with voice and video.... : ' + enable_vv.to_string()) -message('Build with GNU Libidn......... : ' + idn.found().to_string()) message('Build with Nettle support..... : ' + nettle.found().to_string()) message('Build with Cyrus SASL support. : ' + sasl.found().to_string()) message('Use external libzephyr........ : ' + EXTERNAL_LIBZEPHYR.to_string()) diff -r 8066acc5ed93 -r 35b4a6224d6d meson_options.txt --- a/meson_options.txt Mon Dec 30 07:08:44 2019 +0000 +++ b/meson_options.txt Fri Jan 31 08:43:03 2020 -0600 @@ -58,9 +58,6 @@ option('cyrus-sasl', type : 'feature', description : 'enable Cyrus SASL support for XMPP/IRC') -option('idn', type : 'feature', - description : 'compile with IDN support') - option('krb4', type : 'boolean', value : false, description : 'compile Zephyr plugin with Kerberos 4 support')