diff options
author | portix <none@none> | 2013-02-14 13:14:11 +0100 |
---|---|---|
committer | portix <none@none> | 2013-02-14 13:14:11 +0100 |
commit | bc933d6e87a4421101be6121b27cab252ccaf7fd (patch) | |
tree | b7916d36d21bc6ae72505d2ac8535ea9a4152bec /src/domain.c | |
parent | 02d1b0549a11697832b5b15ea66caeb67f04d57f (diff) | |
download | dwb-bc933d6e87a4421101be6121b27cab252ccaf7fd.zip |
Fixing check for supercookies if a cookie domain starts with a dot
Diffstat (limited to 'src/domain.c')
-rw-r--r-- | src/domain.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/domain.c b/src/domain.c index 9aa6f156..29f813b1 100644 --- a/src/domain.c +++ b/src/domain.c @@ -139,11 +139,18 @@ count_char(const char *str, char ch) return count; } -const char * +gboolean +domain_is_tld(const char *host) +{ + g_return_val_if_fail(host != NULL, false); + + return g_hash_table_lookup(s_tld_table, host) != NULL; +} + +const char * domain_get_tld(const char *host) { - if (host == NULL) - return NULL; + g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(s_tld_table != NULL, NULL); const char *cur_domain = host; @@ -157,8 +164,7 @@ domain_get_tld(const char *host) * - cannot start with . * - must only contain A-Za-z0-9.-_ */ - if (nextdot == cur_domain || - strspn(cur_domain, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + if (*cur_domain == '.' || strspn(cur_domain, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrustuvwxyz" "0123456789._-") != strlen(cur_domain)) { return NULL; @@ -187,7 +193,7 @@ domain_get_tld(const char *host) } else if(strcmp(entry, prev_domain) == 0) break; - else if(strcmp(entry, prev_domain) != 0) + else { ret = prev_domain; break; |