From: Christian Dywan Date: Tue, 6 Mar 2012 19:14:15 +0000 (+0100) Subject: Skip empty, invalid and comment lines in adblock_parse_line X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa22841ec9c0de6e9eb9eb9dcff1c57ccecc2f67;p=midori Skip empty, invalid and comment lines in adblock_parse_line --- 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] == '|' ) {