summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmailutils/base/url.c21
-rw-r--r--libmailutils/base/wicket.c8
2 files changed, 21 insertions, 8 deletions
diff --git a/libmailutils/base/url.c b/libmailutils/base/url.c
index 49aab4b18..96345f056 100644
--- a/libmailutils/base/url.c
+++ b/libmailutils/base/url.c
@@ -966,20 +966,25 @@ mu_url_decode (const char *s)
#define is_wildcard(s) ((s)[0] == '*' && s[1] == 0)
+#define WEIGHT_SCHEME 3
+#define WEIGHT_USER 4
+#define WEIGHT_HOST 2
+#define WEIGHT_PORT 1
+
int
mu_url_matches_ticket (mu_url_t ticket, mu_url_t url, int *pwc)
{
int wcnt = 0;
-
+
if (is_wildcard (ticket->scheme))
- wcnt++;
+ wcnt += WEIGHT_SCHEME;
else if (mu_c_strcasecmp (ticket->scheme, url->scheme))
return 0;
if (ticket->flags & MU_URL_HOST)
{
if (is_wildcard (ticket->host))
- wcnt++;
+ wcnt += WEIGHT_HOST;
else if (url->flags & MU_URL_HOST)
{
if (mu_c_strcasecmp (ticket->host, url->host))
@@ -990,7 +995,7 @@ mu_url_matches_ticket (mu_url_t ticket, mu_url_t url, int *pwc)
return 0;
}
else
- wcnt++;
+ wcnt += WEIGHT_HOST;
if (ticket->flags & MU_URL_PORT)
{
@@ -1000,16 +1005,16 @@ mu_url_matches_ticket (mu_url_t ticket, mu_url_t url, int *pwc)
if (ticket->port != url->port)
return 0;
else
- wcnt++;
+ wcnt += WEIGHT_PORT;
}
}
else
- wcnt++;
+ wcnt += WEIGHT_PORT;
if (ticket->flags & MU_URL_USER)
{
if (is_wildcard (ticket->user))
- wcnt += 2;
+ wcnt += WEIGHT_USER;
/* If ticket has a user or pass, but url doesn't, that's OK, we were
looking for this info. But if url does have a user/pass, it
@@ -1021,7 +1026,7 @@ mu_url_matches_ticket (mu_url_t ticket, mu_url_t url, int *pwc)
}
}
else
- wcnt++;
+ wcnt += WEIGHT_USER;
/* Guess it matches. */
if (pwc)
diff --git a/libmailutils/base/wicket.c b/libmailutils/base/wicket.c
index 4d79c2ce4..3e808c0ea 100644
--- a/libmailutils/base/wicket.c
+++ b/libmailutils/base/wicket.c
@@ -284,6 +284,14 @@ mu_wicket_stream_match_url (mu_stream_t stream, struct mu_debug_locus *loc,
mu_url_destroy (&u);
continue;
}
+
+ if (!mu_url_has_flag (u, MU_URL_USER|MU_URL_SECRET))
+ {
+ mu_error (_("%s:%u: URL is missing required parts"),
+ loc->file, loc->line);
+ mu_url_destroy (&u);
+ continue;
+ }
if (!mu_url_matches_ticket (u, url, &n))
{

Return to:

Send suggestions and report system problems to the System administrator.