Introduction
Introduction Statistics Contact Development Disclaimer Help
use non-hardcoded adblock list - surf-adblock - Surf adblock web extension
git clone git://git.codemadness.org/surf-adblock
Log
Files
Refs
README
LICENSE
---
commit 75a5ce0455bace5c6b20ef07ceb202bd0af02269
parent bce9b1e6b8d516ab21f9e23839ae96f82a9cd723
Author: Hiltjo Posthuma <[email protected]>
Date: Sat, 16 Jul 2016 12:11:51 +0200
use non-hardcoded adblock list
Diffstat:
M surf-adblock.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/surf-adblock.c b/surf-adblock.c
@@ -788,16 +788,25 @@ webkit_web_extension_initialize(WebKitWebExtension *e)
{
struct filterrule *r;
FILE *fp;
- const char *filename = "/home/hiltjo/adblock_rules";
+ char filepath[PATH_MAX], *home;
+ int n;
+
+ home = getenv("HOME");
+ n = snprintf(filepath, sizeof(filepath), "%s%s.surf/adblockrules",
+ home ? home : "", home ? "/" : "");
+ if (n < 0 || (size_t)n >= sizeof(filepath)) {
+ fprintf(stderr, "fatal: path too long, truncated\n");
+ return;
+ }
- if (!(fp = fopen(filename, "r"))) {
+ if (!(fp = fopen(filepath, "r"))) {
fprintf(stderr, "fatal: cannot read rules file: %s: %s\n",
- filename, strerror(errno));
+ filepath, strerror(errno));
return;
}
if (!(rules = loadrules(fp))) {
fprintf(stderr, "fatal: cannot read adblock rules from file: %…
- filename, strerror(errno));
+ filepath, strerror(errno));
return;
}
fclose(fp);
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.