Upon checking the lastest release after merging #2433, I noticed
that some subjects with slashes goes through.
This patch fixes that by ignoring subjects which contains slashes.
Indeed, from on:
1. We strip out IPs.
2. We strip out "potential" INVALID that:
- doesn't contains dots
- contains at least 2 consecutive dots
- looks like an IP.
From now on an acceptable subject shall:
1. have at least 1 dot.
2. NOT be an IPv4 or IPv6
3. NOT look like an IP. (Example: 258.300.10.3)
Indeed, even with the original regex, the following test doesn't
pass. Therefore, it is necessary to add it into the tests.
www.example-3045.foobar.com
This patch fixes https://github.com/StevenBlack/hosts/issues/1563#issuecomment-810688754
Indeed, before this patch, the updater was not supporting a RAW (not
hosts) list of domains as input.
Changes:
matches_exclusions():
(new) Support for rule formatted as 'example.com' along with
the pre-existing '0.0.0.0 example.com'.
normalize_rule():
(edit) Apply DRY.
(new) Support the normalization of the rule formatted as
'example.com' along with the pre-existing '0.0.0.0
example.com'.
strip_rule():
(new) Complete rewrite in order to strip all possible lines.
Before this patch, there was no proper sorting and the sources.
As @XhmikosR mentioned in StevenBlack/hosts#1166, without this patch,
the output is totally different in Windows. But let's be honest, if it
is like that under Windows, chances are that the same behavior happens
across different OSes or machines around the globe.
Another reason behind this patch is that - desperate the fact that we
certainly trust @StevenBlack - the integrity of the generated files
could not be guarenteed because of the sorting which may be completely
different from an OS to another and a machine to another.
For those reasons, this patch introduces a unification of the sorting of
all sources.
The idea behind this patch is to have @StevenBlack's ad-hoc hosts
file always on top (1st) and the rest of the sources sorted
alphabetically based on the name of the folder inside the `data`
or `extensions` directory.
This will ensure that we get the same result everywhere.
Concretely speaking, I just added the function (`sort_sources`) which
sorts a given list of sources files. And later on, call the new function
everywhere it was necessary. Tests of the newly introduced function
are also included.
Contributors:
* @ScriptTiger
* @XhmikosR
Notes:
* This patch fix (completely ?) ScriptTiger/hosts#1
* This patch fix https://github.com/StevenBlack/hosts/issues/1166#issuecomment-590511086
This patch fixStevenBlack/hosts#777
This patch:
* Change the default state of keepdomaincomments.
* Indeed, comments are now displayed by default.
* But if you don't need comments, feel free to use the argument.
* Delete the requirement input when calling the `-k` argument.
* Update tests case regarding the new state of keepdomaincomments.
The following files:
* myhosts
* blacklist
* whitelist
can be all be modified by the user for personal usage.
However, git is tracking these files since they exist
in the repository, which makes it difficult to do so
without accidentally pushing one's own customizations.
This commit converts those examples to ".example" files,
which serve as the defaults if one of the files listed
above does not exist.
Closes gh-144.