diff options
-rw-r--r-- | extensions/adblock/extension.vala | 2 | ||||
-rw-r--r-- | extensions/adblock/updater.vala | 37 |
2 files changed, 21 insertions, 18 deletions
diff --git a/extensions/adblock/extension.vala b/extensions/adblock/extension.vala index 23a58dcd..9868f11a 100644 --- a/extensions/adblock/extension.vala +++ b/extensions/adblock/extension.vala @@ -263,7 +263,7 @@ namespace Adblock { string[]? domains = null; string domain = Midori.URI.parse_hostname (uri, null); string[] subdomains = domain.split ("."); - if (subdomains == null) + if (subdomains == null || subdomains.length == 0) return null; int cnt = subdomains.length - 1; var subdomain = new StringBuilder (subdomains[cnt]); diff --git a/extensions/adblock/updater.vala b/extensions/adblock/updater.vala index bcbb9b63..9a1b68f8 100644 --- a/extensions/adblock/updater.vala +++ b/extensions/adblock/updater.vala @@ -100,27 +100,30 @@ namespace Adblock { y = int.parse(date_parts[0]); d = int.parse(date_parts[2]); } + last_updated = new DateTime.local (y, m, d, h, min, 0.0); } else { /* Date in a form of: 20 Mar 2012 12:34 */ string[] parts = last_mod_meta.split (" ", 4); - /* contains time part ? */ - if (parts[3] != null && parts[3].contains (":")) { - string[] time_parts = parts[3].split (":", 2); - h = int.parse(time_parts[0]); - min = int.parse(time_parts[1]); - } - - m = get_month_from_string (parts[1]); - if (parts[2].length == 4) { - y = int.parse(parts[2]); - d = int.parse(parts[0]); - } else { - y = int.parse(parts[0]); - d = int.parse(parts[2]); + if (parts.length >= 3) { + /* contains time part ? */ + if (parts.length >= 4 && parts[3].contains (":")) { + string[] time_parts = parts[3].split (":", 2); + h = int.parse(time_parts[0]); + min = int.parse(time_parts[1]); + } + + m = get_month_from_string (parts[1]); + if (parts[2].length == 4) { + y = int.parse(parts[2]); + d = int.parse(parts[0]); + } else { + y = int.parse(parts[0]); + d = int.parse(parts[2]); + } + last_updated = new DateTime.local (y, m, d, h, min, 0.0); } } - - last_updated = new DateTime.local (y, m, d, h, min, 0.0); - } else { + } + if (last_updated == null) { /* FIXME: use file modification date if there's no update header try { string modified = FileAttribute.TIME_MODIFIED; |