[Xfce4-commits] <midori:master> Adblock: Try to parse more update metadata

Christian Dywan noreply at xfce.org
Sun Sep 2 23:22:04 CEST 2012


Updating branch refs/heads/master
         to d426a4df9e46e7028234f29faded8602329466f8 (commit)
       from 414a5f07aedd085b54503ea3432dcdc27eb381ce (commit)

commit d426a4df9e46e7028234f29faded8602329466f8
Author: Paweł Forysiuk <tuxator at o2.pl>
Date:   Sun Sep 2 21:25:56 2012 +0200

    Adblock: Try to parse more update metadata

 extensions/adblock.c |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/extensions/adblock.c b/extensions/adblock.c
index c894cc2..4096488 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -1556,7 +1556,20 @@ adblock_file_is_up_to_date (gchar* path)
                 days_to_expire = atoi (parts[2]);
                 g_strfreev (parts);
             }
-            if (strncmp ("! Last modified", line, 15) == 0)
+            if (strncmp ("! This list expires after", line, 25) == 0)
+            {
+                gchar** parts = g_strsplit (line, " ", 7);
+
+                if (strncmp (parts[6], "days", 4) == 0)
+                    days_to_expire = atoi (parts[5]);
+                if (strncmp (parts[6], "hours", 5) == 0)
+                    days_to_expire = (atoi (parts[5])) / 24;
+
+                g_strfreev (parts);
+            }
+
+            if (strncmp ("! Last modified", line, 15) == 0
+            ||  strncmp ("! Updated", line, 9) == 0)
             {
                 gchar** parts = g_strsplit (line, ":", 2);
                 timestamp = g_strdup (parts[1] + 1);
@@ -1571,10 +1584,25 @@ adblock_file_is_up_to_date (gchar* path)
 
             GDate* current = g_date_new ();
             GDate* mod_date = g_date_new ();
-            gchar** parts = g_strsplit (timestamp, " ", 4);
+            gchar** parts;
+            gboolean use_dots = FALSE;
+
+            /* Common dates are 20 Mar 2012, 20.08.2012 */
+            if (g_strrstr (timestamp, "."))
+            {
+                use_dots = TRUE;
+                parts = g_strsplit (timestamp, ".", 4);
+            }
+            else
+                parts = g_strsplit (timestamp, " ", 4);
 
             g_date_set_day (mod_date, atoi (parts[0]));
-            g_date_set_month (mod_date, str_month_name_to_gdate (parts[1]));
+
+            if (use_dots)
+                g_date_set_month (mod_date, atoi (parts[1]));
+            else
+                g_date_set_month (mod_date, str_month_name_to_gdate (parts[1]));
+
             g_date_set_year (mod_date, atoi (parts[2]));
             g_strfreev (parts);
 


More information about the Xfce4-commits mailing list