[Xfce4-commits] <midori:master> Skip empty, invalid and comment lines in adblock_parse_line

Christian Dywan noreply at xfce.org
Tue Mar 6 21:44:03 CET 2012


Updating branch refs/heads/master
         to fa22841ec9c0de6e9eb9eb9dcff1c57ccecc2f67 (commit)
       from a83cea4964a5c4395d4ef591e483fa017fd93227 (commit)

commit fa22841ec9c0de6e9eb9eb9dcff1c57ccecc2f67
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Mar 6 20:14:15 2012 +0100

    Skip empty, invalid and comment lines in adblock_parse_line

 extensions/adblock.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/extensions/adblock.c b/extensions/adblock.c
index 4bfd0d8..5f590de 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -1301,12 +1301,10 @@ adblock_frame_add_private (const gchar* line,
 static gchar*
 adblock_parse_line (gchar* line)
 {
-    if (!line)
-        return NULL;
-    g_strchomp (line);
-    /* Ignore comments and new lines */
-    if (line[0] == '!')
+    /* Skip invalid, empty and comment lines */
+    if (!(line && line[0] != ' ' && line[0] != '!' && line[0]))
         return NULL;
+
     /* FIXME: No support for whitelisting */
     if (line[0] == '@' && line[1] == '@')
         return NULL;
@@ -1314,9 +1312,7 @@ adblock_parse_line (gchar* line)
     if (line[0] == '[')
         return NULL;
 
-    /* Skip garbage */
-    if (line[0] == ' ' || !line[0])
-        return NULL;
+    g_strchomp (line);
 
     /* Got CSS block hider */
     if (line[0] == '#' && line[1] == '#' )
@@ -1334,13 +1330,13 @@ adblock_parse_line (gchar* line)
         adblock_frame_add_private (line, "##");
         return NULL;
     }
-
     /* Got per domain CSS hider rule. Workaround */
     if (strchr (line, '#'))
     {
         adblock_frame_add_private (line, "#");
         return NULL;
     }
+
     /* Got URL blocker rule */
     if (line[0] == '|' && line[1] == '|' )
     {


More information about the Xfce4-commits mailing list