summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-05-22 06:05:42 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-05-22 06:05:42 (GMT)
commit0d271c3709f7f3da81285925b670cdb85b90ccbd (patch) (unidiff)
treeb70b8572bb4b1f75c4097183ca9a5f94c4bdf3f4
parentdd213e8c519df45f4a0b632d71691693ddf2502a (diff)
downloadmailutils-0d271c3709f7f3da81285925b670cdb85b90ccbd.tar.gz
mailutils-0d271c3709f7f3da81285925b670cdb85b90ccbd.tar.bz2
URL parser: use case-insensitive comparison for auth and host parts
* libmailutils/url/accessor.h: (URL_PART_CMP_ICASE) (URL_PART_CMP_ICASE): New defines. * libmailutils/url/get-auth.c: Request case-insensitive comparison. * libmailutils/url/get-host.c: Likewise.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libmailutils/url/accessor.h15
-rw-r--r--libmailutils/url/get-auth.c1
-rw-r--r--libmailutils/url/get-host.c1
3 files changed, 15 insertions, 2 deletions
diff --git a/libmailutils/url/accessor.h b/libmailutils/url/accessor.h
index 309a7aa..fa3ed7e 100644
--- a/libmailutils/url/accessor.h
+++ b/libmailutils/url/accessor.h
@@ -34,8 +34,8 @@
34 34
35/* General accessors: */ 35/* General accessors: */
36#define AC2(a,b) a ## b 36#define AC2(a,b) a ## b
37#define METHOD(pfx,part) AC2(pfx,part)
38#define AC4(a,b,c,d) a ## b ## c ## d 37#define AC4(a,b,c,d) a ## b ## c ## d
38#define METHOD(pfx,part) AC2(pfx,part)
39#define ACCESSOR(action,field) AC4(mu_url_,action,_,field) 39#define ACCESSOR(action,field) AC4(mu_url_,action,_,field)
40 40
41/* Define a `static get' accessor */ 41/* Define a `static get' accessor */
@@ -123,6 +123,17 @@ ACCESSOR(aget, URL_PART) (mu_url_t url, char **buf)
123 return status; 123 return status;
124} 124}
125 125
126#ifndef URL_PART_CMP
127# ifndef URL_PART_CMP_ICASE
128# define URL_PART_CMP_ICASE 0
129# endif
130# if URL_PART_CMP_ICASE
131# define URL_PART_CMP mu_c_strcasecmp
132# else
133# define URL_PART_CMP strcmp
134# endif
135#endif
136
126/* Define a comparator */ 137/* Define a comparator */
127int 138int
128ACCESSOR(is_same,URL_PART) (mu_url_t url1, mu_url_t url2) 139ACCESSOR(is_same,URL_PART) (mu_url_t url1, mu_url_t url2)
@@ -139,5 +150,5 @@ ACCESSOR(is_same,URL_PART) (mu_url_t url1, mu_url_t url2)
139 150
140 if (status1 || status2) 151 if (status1 || status2)
141 return status1 == status2; /* Both fields are missing */ 152 return status1 == status2; /* Both fields are missing */
142 return mu_c_strcasecmp (s1, s2) == 0; 153 return URL_PART_CMP (s1, s2) == 0;
143} 154}
diff --git a/libmailutils/url/get-auth.c b/libmailutils/url/get-auth.c
index b9650a5..c8c7ca7 100644
--- a/libmailutils/url/get-auth.c
+++ b/libmailutils/url/get-auth.c
@@ -1,3 +1,4 @@
1#define URL_PART auth 1#define URL_PART auth
2#define URL_PART_CMP_ICASE 1
2#include "accessor.h" 3#include "accessor.h"
3 4
diff --git a/libmailutils/url/get-host.c b/libmailutils/url/get-host.c
index 6de6b56..9ef6db8 100644
--- a/libmailutils/url/get-host.c
+++ b/libmailutils/url/get-host.c
@@ -1,2 +1,3 @@
1#define URL_PART host 1#define URL_PART host
2#define URL_PART_CMP_ICASE 1
2#include "accessor.h" 3#include "accessor.h"

Return to:

Send suggestions and report system problems to the System administrator.