diff options
author | Peter Hofmann <scm@uninformativ.de> | 2014-06-19 10:15:36 +0200 |
---|---|---|
committer | Peter Hofmann <scm@uninformativ.de> | 2014-06-19 10:15:36 +0200 |
commit | 712ef58dba17f7817f0ed77b74594fda49b90ea3 (patch) | |
tree | 4637e639e092490ff8321c87bafc7bb24eda1bfb /browser.c | |
parent | 13987df7e800305b03013fd743ab12fa1621a67a (diff) | |
download | lariza-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.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -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); } } |