From fa22841ec9c0de6e9eb9eb9dcff1c57ccecc2f67 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 6 Mar 2012 20:14:15 +0100 Subject: [PATCH] Skip empty, invalid and comment lines in adblock_parse_line --- extensions/adblock.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/extensions/adblock.c b/extensions/adblock.c index 4bfd0d81..5f590de5 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] == '|' ) { -- 2.39.5