summaryrefslogtreecommitdiff
path: root/browser.c
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2014-06-19 10:15:36 +0200
committerPeter Hofmann <scm@uninformativ.de>2014-06-19 10:15:36 +0200
commit712ef58dba17f7817f0ed77b74594fda49b90ea3 (patch)
tree4637e639e092490ff8321c87bafc7bb24eda1bfb /browser.c
parent13987df7e800305b03013fd743ab12fa1621a67a (diff)
downloadlariza-712ef58dba17f7817f0ed77b74594fda49b90ea3.tar.gz
adblock_load(): Fix invalid regexes, support comments
- Invalid regexes are no longer added to the list. - Lines starting with a "#" are ignored.
Diffstat (limited to 'browser.c')
-rw-r--r--browser.c21
1 files 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);
}
}