]> granicus.if.org Git - neomutt/commitdiff
tidy idna
authorRichard Russon <rich@flatcap.org>
Sat, 14 Jul 2018 21:20:46 +0000 (22:20 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 16 Jul 2018 22:47:18 +0000 (23:47 +0100)
email/idna.c
email/url.c

index 159eb47f6e91609e0bba5a39f6fb65ef7f484c79..08886a277121350ebf3ed6b95fb9eed77bae1dcb 100644 (file)
@@ -70,23 +70,6 @@ bool IdnEncode;
 #endif /* HAVE_LIBIDN */
 
 #ifdef HAVE_LIBIDN
-/**
- * mutt_idna_to_ascii_lz - Convert a domain to Punycode
- * @param input  Domain
- * @param output Result
- * @param flags  Flags, e.g. IDNA_ALLOW_UNASSIGNED
- * @retval 0 Success
- * @retval >0 Failure, error code
- *
- * Convert a domain from the current locale to Punycode.
- *
- * @note The caller must free output
- */
-int mutt_idna_to_ascii_lz(const char *input, char **output, int flags)
-{
-  return idna_to_ascii_lz(input, output, flags);
-}
-
 /**
  * check_idn - Is domain in Punycode?
  * @param domain Domain to test
@@ -108,6 +91,23 @@ static bool check_idn(char *domain)
 
   return false;
 }
+
+/**
+ * mutt_idna_to_ascii_lz - Convert a domain to Punycode
+ * @param input  Domain
+ * @param output Result
+ * @param flags  Flags, e.g. IDNA_ALLOW_UNASSIGNED
+ * @retval 0 Success
+ * @retval >0 Failure, error code
+ *
+ * Convert a domain from the current locale to Punycode.
+ *
+ * @note The caller must free output
+ */
+int mutt_idna_to_ascii_lz(const char *input, char **output, int flags)
+{
+  return idna_to_ascii_lz(input, output, flags);
+}
 #endif /* HAVE_LIBIDN */
 
 /**
index 7dd63a2d832ae9d5d4bafab63f433dac7d1707ba..39958c0bb4a44e457a7e2287a8eac3a1e2f439d5 100644 (file)
@@ -44,6 +44,51 @@ static const struct Mapping UrlMap[] = {
   { "smtp", U_SMTP },   { "smtps", U_SMTPS },   { NULL, U_UNKNOWN },
 };
 
+/**
+ * parse_query_string - Parse a URL query string
+ * @param u Url to store the results
+ * @param src String to parse
+ * @retval  0 Success
+ * @retval -1 Error
+ */
+static int parse_query_string(struct Url *u, char *src)
+{
+  struct UrlQueryString *qs = NULL;
+  char *k = NULL, *v = NULL;
+
+  while (src && *src)
+  {
+    qs = mutt_mem_calloc(1, sizeof(struct UrlQueryString));
+    k = strchr(src, '&');
+    if (k)
+      *k = '\0';
+
+    v = strchr(src, '=');
+    if (v)
+    {
+      *v = '\0';
+      qs->value = v + 1;
+      if (url_pct_decode(qs->value) < 0)
+      {
+        FREE(&qs);
+        return -1;
+      }
+    }
+    qs->name = src;
+    if (url_pct_decode(qs->name) < 0)
+    {
+      FREE(&qs);
+      return -1;
+    }
+    STAILQ_INSERT_TAIL(&u->query_strings, qs, entries);
+
+    if (!k)
+      break;
+    src = k + 1;
+  }
+  return 0;
+}
+
 /**
  * url_pct_decode - Decode a percent-encoded string
  * @param s String to decode
@@ -107,51 +152,6 @@ enum UrlScheme url_check_scheme(const char *s)
     return (enum UrlScheme) i;
 }
 
-/**
- * parse_query_string - Parse a URL query string
- * @param u Url to store the results
- * @param src String to parse
- * @retval  0 Success
- * @retval -1 Error
- */
-static int parse_query_string(struct Url *u, char *src)
-{
-  struct UrlQueryString *qs = NULL;
-  char *k = NULL, *v = NULL;
-
-  while (src && *src)
-  {
-    qs = mutt_mem_calloc(1, sizeof(struct UrlQueryString));
-    k = strchr(src, '&');
-    if (k)
-      *k = '\0';
-
-    v = strchr(src, '=');
-    if (v)
-    {
-      *v = '\0';
-      qs->value = v + 1;
-      if (url_pct_decode(qs->value) < 0)
-      {
-        FREE(&qs);
-        return -1;
-      }
-    }
-    qs->name = src;
-    if (url_pct_decode(qs->name) < 0)
-    {
-      FREE(&qs);
-      return -1;
-    }
-    STAILQ_INSERT_TAIL(&u->query_strings, qs, entries);
-
-    if (!k)
-      break;
-    src = k + 1;
-  }
-  return 0;
-}
-
 /**
  * url_parse - Fill in Url
  * @param u   Url where the result is stored