Title: Domain validator allows invalid characters in some cases · Issue #366 · python-validators/validators · GitHub
Open Graph Title: Domain validator allows invalid characters in some cases · Issue #366 · python-validators/validators
X Title: Domain validator allows invalid characters in some cases · Issue #366 · python-validators/validators
Description: It appears that, currently, any character is valid for the final character in the gTLD if rfc1034 is True, for example: >>> domain('example.com?', rfc_1034=True, rfc_2782=False) True >>> domain('example.com!', rfc_1034=True, rfc_2782=Fal...
Open Graph Description: It appears that, currently, any character is valid for the final character in the gTLD if rfc1034 is True, for example: >>> domain('example.com?', rfc_1034=True, rfc_2782=False) True >>> domain('ex...
X Description: It appears that, currently, any character is valid for the final character in the gTLD if rfc1034 is True, for example: >>> domain('example.com?', rfc_1034=True, rfc_2782=False) Tr...
Opengraph URL: https://github.com/python-validators/validators/issues/366
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Domain validator allows invalid characters in some cases","articleBody":"It appears that, currently, any character is valid for the final character in the gTLD if `rfc1034` is `True`, for example:\r\n```\r\n\u003e\u003e\u003e domain('example.com?', rfc_1034=True, rfc_2782=False)\r\nTrue\r\n\u003e\u003e\u003e domain('example.com!', rfc_1034=True, rfc_2782=False)\r\nTrue\r\n```\r\n\r\nI believe the '.' just needs to be escaped in the pattern string ([link](https://github.com/python-validators/validators/blob/master/src/validators/domain.py#L72)):\r\n```\r\n+ rf\"[a-z]{r'.?$' if rfc_1034 else r'$'}\",\r\n ^\r\n```\r\n\r\nAlso, it appears question marks are allowed when `rfc_2782` is `True` for domain validation:\r\n```\r\n\u003e\u003e\u003e from validators import domain\r\n\u003e\u003e\u003e domain('example?.com', rfc_1034=False, rfc_2782=True)\r\nTrue\r\n```\r\nThis appears to be from the use of '?' after the '_' inside of a character class:\r\n```\r\nrf\"^(?:[a-z0-9{r'_?'if rfc_2782 else ''}]\"\r\n ^\r\n```\r\nPresumably, this is to make the '_' optional, but since metacharacters aren't active in character classes ([link](https://docs.python.org/3/howto/regex.html#:~:text=a%2Dz%5D.-,Metacharacters,-(except%20%5C)%20are)), this is interpreted as a literal '?' instead. \r\n\r\n","author":{"url":"https://github.com/hagenrd","@type":"Person","name":"hagenrd"},"datePublished":"2024-04-17T22:24:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/366/validators/issues/366"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:02000250-4ee3-5647-581c-b9c5d58b2f5c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E398:1159E3:1137A3:16941A:698EB8B0 |
| html-safe-nonce | 42db0c2d5cf73ea89fe675ba57ac98a8d034a7135f7446fa05ba19a15f9d4b32 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzk4OjExNTlFMzoxMTM3QTM6MTY5NDFBOjY5OEVCOEIwIiwidmlzaXRvcl9pZCI6IjQ2MTg0NDc2OTg4ODE1OTE0NzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d65a9cd673dcad411cb8c3263e858735f4de6101ff0d3a87c229ec9f468d373b |
| hovercard-subject-tag | issue:2249368814 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-validators/validators/366/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b2407cb8390c945dae045699e77ae4c653f3900196b8170a7015d91218b951ab/python-validators/validators/issues/366 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b2407cb8390c945dae045699e77ae4c653f3900196b8170a7015d91218b951ab/python-validators/validators/issues/366 |
| og:image:alt | It appears that, currently, any character is valid for the final character in the gTLD if rfc1034 is True, for example: >>> domain('example.com?', rfc_1034=True, rfc_2782=False) True >>> domain('ex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hagenrd |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb2828a801ee6b7be618f3ac76fbf55def35bbc30f053a9c41bf90210b8b72ba |
| turbo-cache-control | no-preview |
| go-import | github.com/python-validators/validators git https://github.com/python-validators/validators.git |
| octolytics-dimension-user_id | 113113270 |
| octolytics-dimension-user_login | python-validators |
| octolytics-dimension-repository_id | 13642984 |
| octolytics-dimension-repository_nwo | python-validators/validators |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13642984 |
| octolytics-dimension-repository_network_root_nwo | python-validators/validators |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6b91a7e6e46287d26887e3fb7a4161657bab8f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width