Introduction
Introduction Statistics Contact Development Disclaimer Help
wip - surf-adblock - Surf adblock web extension
git clone git://git.codemadness.org/surf-adblock
Log
Files
Refs
README
LICENSE
---
commit 4bdd720660034ff1d771b209dba2097b10dc4d65
parent 182fbfa07b91c9d882ce592414e230e7a7c57c23
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 4 Jun 2017 14:58:31 +0200
wip
Diffstat:
M TODO | 1 +
M adblock.c | 16 ++++++++++------
M tests/run.sh | 4 +++-
M tests/tests.c | 25 ++++++++++++++++++-------
4 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/TODO b/TODO
@@ -1,6 +1,7 @@
- optimize towupper for fnmatch? check < 128, see musl optimization.
- fix blocking of : ||ads.somesite.com^
+ matchbegin and matchend rules are wrong.
- fix tweakers.net popup / rule.
this is in an exception rule...
diff --git a/adblock.c b/adblock.c
@@ -776,10 +776,11 @@ getdocumentcss(const char *uri)
if (!uri)
return NULL;
- if (!(s = strstr(uri, "://")))
- return NULL;
- s += sizeof("://") - 1;
- len = strcspn(s, "/");
+ if ((s = strstr(uri, "://")))
+ s += sizeof("://") - 1;
+ else
+ s = uri;
+ len = strcspn(s, "/"); /* TODO: ":/" */
memcpy(domain, s, len);
domain[len] = '\0';
@@ -848,8 +849,11 @@ checkrequest(const char *uri, const char *requri)
if (!uri || !strcmp(requri, uri))
return 1;
- s = strstr(uri, "://") + sizeof("://") - 1;
- len = strcspn(s, "/");
+ if ((s = strstr(uri, "://")))
+ s += sizeof("://") - 1;
+ else
+ s = uri;
+ len = strcspn(s, "/"); /* TODO: ":/" */
memcpy(domain, s, len);
domain[len] = '\0';
diff --git a/tests/run.sh b/tests/run.sh
@@ -1,4 +1,6 @@
#!/bin/sh
rm -f *.o tests
-cc tests.c -o tests -Wall
+#cc tests.c -o tests -Wall -ggdb -O0
+#cc tests.c -o tests -Wall -ggdb -Os
+cc tests.c -o tests -O2 -Wall
SURF_ADBLOCK_FILE=`pwd`/rules ./tests
diff --git a/tests/tests.c b/tests/tests.c
@@ -7,27 +7,38 @@ main(void)
init();
- status = checkrequest("https://tweakers.net/", "/adtracker/a");
+ status = checkrequest("https://tweakers.net/", "https://tweakers.net/a…
printf("%d\n", status);
- status = checkrequest("https://tweakers.net/", "/adtracker.");
+ status = checkrequest("http://tweakers.net/", "http://tweakers.net/adt…
printf("%d\n", status);
- status = checkrequest("https://tweakers.net/", "/index.html");
+ status = checkrequest("https://tweakers.net/", "https://tweakers.net/a…
printf("%d\n", status);
- status = checkrequest("https://360ads.com/", "/index.html");
+ status = checkrequest("https://tweakers.net/", "https://tweakers.net/i…
printf("%d\n", status);
- status = checkrequest("https://www.360ads.com/", "/index.html");
+ status = checkrequest("https://360ads.com/", "https://360ads.com/index…
printf("%d\n", status);
- status = checkrequest("https://360ads.com:8000/", "/index.html");
+ status = checkrequest("https://www.360ads.com/", "https://www.360ads.c…
printf("%d\n", status);
- status = checkrequest("https://www.360ads.com:8000/", "/index.html");
+ status = checkrequest("http://www.360ads.com/", "http://360ads.com/ind…
printf("%d\n", status);
+ status = checkrequest("https://360ads.com:8000/", "https://360ads.com/…
+ printf("%d\n", status);
+
+ status = checkrequest("https://360ads.com/", "https://360ads.com:8000/…
+ printf("%d\n", status);
+
+ status = checkrequest("https://360ads.com:8000/", "https://360ads.com:…
+ printf("%d\n", status);
+
+ /*http://statics.360ads.com/statics/images/2016/home/t3.png*/
+
cleanup();
return 0;
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.