73 Commits

Author SHA1 Message Date
080d276bb7 Issue #2785: fix — ignore domains ending with a dot. 2024-12-16 20:53:49 -04:00
870ade3522 Correct 2nd Iter: Ignore subject with slashes (/).
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.
2023-09-08 18:45:30 +02:00
3b4709f25f Correct 2nd Iter: Hostnames to lowercase.
As mentioned by @StevenBlack in #2400, hostnames should be
converted to lowercase.
2023-09-07 18:46:54 +02:00
65ebac6bf8 Fix tests and logic.
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)
2023-09-06 21:57:22 +02:00
33bd0df131 Fix linting issue-s 2023-09-03 13:17:24 +02:00
560615dd7f Add support for exotic TLDs.
Indeed, before this patch, we were not supporting TLD which
contains digits and dashes (-) when "puny-encoded".
2023-08-10 16:35:38 +02:00
3b2c9dda2b Add new test case.
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
2023-08-05 21:00:55 +02:00
1f3f3236ed 2nd Iter: Ensure that hostnames without dots are excluded.
This patch fixes #2347.

Indeed, my previous patch was missing domains with dashes (-).
2023-08-05 20:43:10 +02:00
7e25ed039a Ensure that hostnames without dots are excluded.
This patch fixes #2347.
2023-07-26 15:06:21 +02:00
6d48930c6f Add versions that only render the extensions 2023-06-11 22:32:05 -04:00
69dd5790cf test source existence; actually fix tests 2022-07-06 13:07:02 -04:00
dccb1e220f remove 3.6; fix tests 2022-07-06 12:47:38 -04:00
177e9755a3 Use assertIn instead of assertTrue 2022-03-07 09:08:23 +02:00
bce4b79920 removed a manual indexer iterator pitfall from the code 2021-10-24 14:06:53 -03:00
4f6ddfaab8 Blacking. 2021-07-13 20:14:25 +02:00
023eb7faa7 Issue #1628: fix — parse out @ characters from lists. 2021-04-26 17:55:39 -04:00
2b167dcce8 Better name for is_valid_user_provided_domain_format. 2021-04-26 17:08:38 -04:00
4b1a939668 Apply black+isort 2021-03-31 14:57:56 +02:00
7971a0cbc9 Introduction of the support of RAW lines.
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.
2021-03-31 14:53:22 +02:00
f6d8977748 docs: fix simple typo, seprator -> separator
There is a small typo in testUpdateHostsFile.py.

Should read `separator` rather than `seprator`.
2020-12-22 08:16:04 +11:00
b350c68540 Improved tests for get_file_by_url 2020-09-02 20:25:01 -04:00
d85c96576a Remove unused test code 2020-08-28 03:18:41 -04:00
ad35681244 Improve tests for get_file_by_url 2020-08-28 03:17:06 -04:00
26b2ab9e5a Add basic tests for get_file_by_url 2020-08-25 20:40:30 -04:00
aa9da1ee0d Remove unused import in tests 2020-08-21 17:30:47 -04:00
5186071948 Introduce the requests library.
Replace the combination of urllib, beautifulsoup and lxml with the requests library.
2020-08-17 19:52:11 -04:00
24f7482fc6 Remove unnecessary reset_mock calls 2020-08-09 00:42:24 -07:00
a09e408c8a Merge pull request #1342 from codeswhite/patch-network-retry
Implemented connectivity check (Fixed #1038)
2020-07-13 13:41:19 -04:00
abf763e9a0 Change strategy regarding #1332.
Instead of changing the directory separator globally, we change it only
when we generate/update the readme data file.
2020-07-13 15:35:16 +02:00
b8b067b6ab Replace the returned separator under Windows. 2020-07-13 11:29:11 +02:00
c756858a1b Merge branch 'master' into issue-1332 2020-07-13 11:23:45 +02:00
f26168194b Retry to get file from URL once failed
(Resolves #1038)
2020-07-11 14:09:51 +03:00
9e3db93d92 Updated test 2020-07-10 23:43:09 +03:00
73479bc632 Fix directory separtor under Windows.
This patch fix #1332.
2020-07-10 01:04:44 +02:00
a2008b78f9 First, format with black. 2020-05-27 21:59:34 +02:00
b40aa38ee6 remove the '-' from mock 2020-04-24 21:13:41 +02:00
f5358fd0b4 Join a few short lines and fixes a few typos 2020-04-23 09:02:38 +03:00
665dc98191 Unification of the sorting of the sources.
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
2020-04-21 22:54:25 +02:00
7dd582dac3 2 blank lines? 2020-04-07 23:07:40 -07:00
9c1b8b2579 use more succinct name for arg 2020-04-07 22:40:30 -07:00
aec3738838 fix unit test 2020-04-07 22:18:35 -07:00
d2566110ff Fix GitHub capitalization 2020-02-22 16:21:26 +02:00
05dad7e657 Introduction of Black: The uncompromising Python code formatter.
Please find more about it there:
* https://github.com/python/black
* https://black.readthedocs.io/en/stable/
2019-07-13 13:40:13 +02:00
c0d661f388 Review of the notion of keepdomaincomments
This patch fix StevenBlack/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.
2018-09-14 00:15:56 +02:00
92442955bc Minor house-cleaning
* No parentheses single-line string
* Remove builtins function, which was
really for Python 2.x compatibility
2018-09-06 21:12:48 -07:00
d8df5f1dc4 Use example files to allow proper git-ignoring
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.
2018-09-06 12:20:37 -07:00
7c2da6044e Deletion of unneeded comment 2018-09-05 23:53:57 -04:00
782a178596 This patch fix https://github.com/StevenBlack/hosts/pull/730#discussion_r205657347 2018-09-05 23:53:57 -04:00
e246960c43 Fixing flake8 issues 2018-09-05 23:53:57 -04:00
58db5143ed Deletion of future dependencies
Also:
  * deletion of raw_input
2018-09-05 23:53:35 -04:00