]> git.armaanb.net Git - chorizo.git/blobdiff - browser.c
adblock_load(): Fix invalid regexes, support comments
[chorizo.git] / browser.c
index 4d6ea04b82e92205e0c99f89ba08410a405e15d2..4bd69ee53db743cb1bcced28268196bf04eccfe2 100644 (file)
--- 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);
                }
        }