From 712ef58dba17f7817f0ed77b74594fda49b90ea3 Mon Sep 17 00:00:00 2001 From: Peter Hofmann Date: Thu, 19 Jun 2014 10:15:36 +0200 Subject: [PATCH] adblock_load(): Fix invalid regexes, support comments - Invalid regexes are no longer added to the list. - Lines starting with a "#" are ignored. --- browser.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/browser.c b/browser.c index 4d6ea04..4bd69ee 100644 --- a/browser.c +++ b/browser.c @@ -134,17 +134,20 @@ adblock_load(void) == G_IO_STATUS_NORMAL) { g_strstrip(buf); - re = g_regex_new(buf, - G_REGEX_CASELESS | G_REGEX_OPTIMIZE, - G_REGEX_MATCH_PARTIAL, &err); - if (err != NULL) + if (buf[0] != '#') { - fprintf(stderr, __NAME__": Could not compile regex: %s\n", buf); - g_error_free(err); - err = NULL; + re = g_regex_new(buf, + G_REGEX_CASELESS | G_REGEX_OPTIMIZE, + G_REGEX_MATCH_PARTIAL, &err); + if (err != NULL) + { + fprintf(stderr, __NAME__": Could not compile regex: %s\n", buf); + g_error_free(err); + err = NULL; + } + else + adblock_patterns = g_slist_append(adblock_patterns, re); } - adblock_patterns = g_slist_append(adblock_patterns, re); - g_free(buf); } } -- 2.39.2