T145 / black-mirror

Blacklists and whitelists built by open code, so you know what goes into them.
GNU Affero General Public License v3.0
186 stars 12 forks source link

[bug]: Minor Awk regex bug when processsing schakal #190

Closed T145 closed 2 months ago

T145 commented 2 months ago

Contact Details

No response

What happened?

The following command:

mawk '$1~/^(0.0.0.0|127.0.0.1|0|::)$/&&$2!~/^(localhost|local|localhost.localdomain)$/{print $2}' alive_hosts.txt | head

Performed on the schakal list prints the given output, when the "localhost" is not expected to be included.

What's confusing is the 127.0.0.1 localhost entry isn't ignored, but in other lists that use that same statement (like KodoPenguin's GameIndustry list) it is.

This regex works on all other hosts files, so again this is strange. Maybe an issue with line endings?

Operating System

Debian Bookworm

Relevant log output

localhost
0-02pw.cfd
0-2lyb.sbs
0-47pc.cfd
0-6n10.sbs
0-84-4a0455e3-22d8-4d50-afd7-8f5cf0f75e65.analytics.mobilegamestats.com
0-9m4v.sbs
0-avn0.sbs
0-finanzierung.com
0-okodukai.com

Code of Conduct

jarelllama commented 2 months ago

Seems to be the carriage return characters (had to use awk here since I'm testing this on a mobile emulator)

$ awk '$1~/^(0.0.0.0|127.0.0.1|0|::)$/&&$2!~/^(localhost|local|localhost.localdomain)$/{print $2}' a | grep localhost
localhost
localhost.store.pay.florencerepairs.com
nlocalhost.wordtheminer.com
www.localhost.store.pay.florencerepairs.com

$ sed -i 's/\r//g' a
$ awk '$1~/^(0.0.0.0|127.0.0.1|0|::)$/&&$2!~/^(localhost|local|localhost.localdomain)$/{print $2}' a | grep localhost
localhost.store.pay.florencerepairs.com
nlocalhost.wordtheminer.com
www.localhost.store.pay.florencerepairs.com
T145 commented 2 months ago

Thanks for verifying! A quick sub(/\r$/, "") should fix it then.