Skip to content

Commit

Permalink
Fix issue regarding subdomain which starts with digits.
Browse files Browse the repository at this point in the history
This patch fixes #146.

Indeed, before this patch, I never through about testing such cases.
That leaded to this issue: Sub-Domains matching the new cases didn't
passed the syntax checker.

Contributors:
  * @spirillen
  • Loading branch information
funilrys committed Dec 27, 2020
1 parent 1d328ef commit aac8ee6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion PyFunceble/checker/syntax/subdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SubDomainSyntaxChecker(DomainSyntaxCheckerBase):
"""

# pylint: disable=line-too-long
REGEX_VALID_SUBDOMAIN: str = r"^(?=.{0,253}$)(([a-z0-9_][a-z0-9-_]{0,61}[a-z0-9_-]|[a-z0-9])\.)+((?=.*[^0-9])([a-z0-9][a-z0-9-]{0,61}[a-z0-9]|[a-z0-9]))$"
REGEX_VALID_SUBDOMAIN: str = r"^(?=.{0,253}$)(([a-z0-9_][a-z0-9-_]{0,61}[a-z0-9_-]|[a-z0-9])\.)+((?=.*)([a-z0-9][a-z0-9-]{0,61}[a-z0-9]|[a-z0-9]))$"

@DomainSyntaxCheckerBase.ensure_subject_is_given
def is_valid(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion PyFunceble/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from PyFunceble.storage_facility import get_config_directory

PROJECT_NAME: str = "PyFunceble"
PROJECT_VERSION: str = "4.0.0a33.dev (Blue Duckling)"
PROJECT_VERSION: str = "4.0.0a34.dev (Blue Duckling)"

DISTRIBUTED_CONFIGURATION_FILENAME: str = ".PyFunceble_production.yaml"
DISTRIBUTED_DIR_STRUCTURE_FILENAME: str = "dir_structure_production.json"
Expand Down
4 changes: 2 additions & 2 deletions tests/checker/syntax/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_is_not_valid_not_rfc_compliant(self) -> None:
given = "example.hello_world.org"
actual = DomainSyntaxChecker(given).is_valid()

self.assertEqual(expected, actual)
self.assertEqual(expected, actual, given)

def test_is_valid_second_lvl_domain(self) -> None:
"""
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_is_not_valid_subdomain(self) -> None:
domain_checker.subject = subject
actual = domain_checker.is_valid_subdomain()

self.assertEqual(expected, actual)
self.assertEqual(expected, actual, subject)


if __name__ == "__main__":
Expand Down
4 changes: 4 additions & 0 deletions tests/pyf_test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"example.net",
"example.co.uk",
"example.de",
"985.com",
]

NOT_VALID_SECOND_LVL_DOMAINS: List[str] = [
Expand Down Expand Up @@ -126,6 +127,7 @@
"coinbȧse.com",
"cryptopiạ.com",
"cṙyptopia.com",
"985.com",
]

NOT_VALID_DOMAINS: List[str] = [
Expand Down Expand Up @@ -175,6 +177,8 @@
"hello-.example.co.uk",
"hello.world.onion",
"test.hello.blogspot.co.uk",
"888.0769.com",
"1661599812.hello.985.com",
]

NOT_VALID_SUBDOMAINS: List[str] = [
Expand Down
2 changes: 1 addition & 1 deletion version.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
current_version: 4.0.0a33.dev (Blue Duckling)
current_version: 4.0.0a34.dev (Blue Duckling)
deprecated:
- 3.0.21
- 3.1.20
Expand Down

0 comments on commit aac8ee6

Please sign in to comment.