330 Commits

Author SHA1 Message Date
080d276bb7 Issue #2785: fix — ignore domains ending with a dot. 2024-12-16 20:53:49 -04:00
ae8c5b1cba updateHostsFile.py: use a raw string for comment
This fixes a SyntaxWarning with Python 3.12:

```
 /home/runner/work/hosts/hosts/updateHostsFile.py:1386: SyntaxWarning: invalid escape sequence '\W'
  """
```
2024-04-03 08:18:10 +03:00
0c12f19ab5 Fix return type in prompt_for_update 2023-12-12 07:34:10 +02: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
272659110c Fix logical issue. 2023-09-03 15:11:00 +02:00
fed5590f26 Fix minor logical issue. 2023-09-03 13:33:33 +02:00
8fc7f948a8 Remove any potential invalid entries.
- Anything that looks like an IP will be ignored.
- Anything that doesn't containt dots will be ignored.
2023-09-03 13:12:41 +02:00
b3f93f1528 Add an regexless alternative.
This "regexless" alternative just try to implement a more
"generic" solution to the actual "problem".

Please note that this commit will fail tests, because this commit
assume that IPs are not correct rules.

Please also note that the following test will also fail because
the new implementation assume that is actually a parsable
rule. @StevenBlack need to take a decision regarding that one rule.

	0.0.0 google

Also:
  * My editor "blacked" the file.
2023-09-03 11:22:38 +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
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
1892e80aa4 Reverting changes in PR ##2391. 2023-07-27 15:34:13 -04:00
7e25ed039a Ensure that hostnames without dots are excluded.
This patch fixes #2347.
2023-07-26 15:06:21 +02:00
0ea9a40158 Make sure to close files 2023-06-11 22:32:17 -04:00
6d48930c6f Add versions that only render the extensions 2023-06-11 22:32:05 -04:00
0a76a88a38 Create a hostfile or directory of it does not exist 2023-06-11 22:31:34 -04:00
32edd9298d Fix failing CI test. 2023-01-27 22:57:22 -05:00
b676693b0c Issue #2213: fix — deny IPv6 addresses from entering the raw hosts rule test. 2023-01-27 22:45:47 -05:00
f58a9138f4 Add MacOS to check to sudo overwrite hostfile
Someone removed the check for MacOS making the replace step be skipped if the OS was Darwin (MacOS)
2022-07-27 10:48:00 +02:00
057f4ed0f4 Fix breakage for Linux
Partially revert commit 0a99194b28 to fix #2015
2022-07-25 12:22:30 +00:00
159db62a83 step inbetween to reduce failure problems 2022-07-06 13:08:25 -04:00
69dd5790cf test source existence; actually fix tests 2022-07-06 13:07:02 -04:00
6caf8a5244 now really fix windows 2022-07-05 13:19:01 -04:00
0a99194b28 fix windows sudo and replace 2022-07-05 12:54:31 -04:00
258b10edc9 refactor: more containerization 2022-07-05 12:39:02 -04:00
0677b534b1 We can now use a "pause" key in update.json to pause updates from specific sources. 2022-05-13 12:20:37 -04:00
7bf15bf336 Use https in more places 2022-03-12 10:32:32 +02:00
907c2f5cdc Update the requests' docs URL 2021-12-12 16:10:35 +02:00
4f6ddfaab8 Blacking. 2021-07-13 20:14:25 +02:00
6299aebe61 Fix whitelisting issue when RAW list are given.
This patch fixes #1687.

Indeed, before this patch, the whitelisting of a RAW/Plain list of domain
was overlooked.
2021-07-13 20:11:28 +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
1d515c1de3 Standardize the exclusionregexs symbol. 2021-04-26 16:39:07 -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
af9cc115a9 Issue #1464: fix — force a new line prior to the End comment statement. 2020-11-15 13:32:36 -05:00
59ddd34d0e Changed dependency-related exception to be compatible with Python versions < 3.6 2020-08-28 01:51:14 -04:00
1019c6ae00 Improve the error raised when the new dependency is missing 2020-08-28 00:17:50 -04:00
06483cca1d Update error handling in get_file_by_url
I don't believe the the .text could actually raise that exception. Oops.
2020-08-25 20:48:35 -04:00
083db6955e Implement error handling and improve documentation in get_file_by_url 2020-08-25 18:28:21 -04:00
9380fe534e Tweak output formatting of get_file_by_url 2020-08-21 14:44:27 -04:00
beca76acfe Tweak get_file_by_url 2020-08-20 20:00:36 -04:00
4fefecf2e3 Document get_file_by_url 2020-08-20 18:42:31 -04:00
44f41c317b Document get_file_by_url 2020-08-20 17:01:11 -04:00
140c0bd29e Use domain_to_idna in get_file_by_url 2020-08-20 16:15:37 -04:00
79bd7d4122 Tell requests to detect encoding.
Changed the get_file_by_url function to infer/guess the encoding of the content we receive.
2020-08-18 19:36: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
a09e408c8a Merge pull request #1342 from codeswhite/patch-network-retry
Implemented connectivity check (Fixed #1038)
2020-07-13 13:41:19 -04:00
2abefc7cfa Fixed retrying 2020-07-13 18:05:35 +03:00