Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement : add domain name validation #894

Open
neyzth opened this issue Oct 23, 2024 · 11 comments
Open

improvement : add domain name validation #894

neyzth opened this issue Oct 23, 2024 · 11 comments
Assignees
Labels
enhancement New feature or request workaround Workaround fixes problem

Comments

@neyzth
Copy link

neyzth commented Oct 23, 2024

Hello, as a IT guy i have to work sometimes with domain name, not url. Something to check if the input like :

corebackbone.par.franceix.net

or

vl223.par-itx5-dist-2.cdn77.com

have a valid domain name syntax.

Is this possible to add a action for validating this kind of inputs please ?

@fabian-hiller
Copy link
Owner

Yes, we can add a domain action. Is there any regex you would recommend? Would you be interested in creating a PR?

@fabian-hiller fabian-hiller self-assigned this Oct 24, 2024
@fabian-hiller fabian-hiller added the enhancement New feature or request label Oct 24, 2024
@neyzth
Copy link
Author

neyzth commented Oct 24, 2024

hi, this kind of regex i guess :

^((?!-)[A-Za-z0-9-]{1,63}(?<!-).)+[A-Za-z]{2,}$

@fabian-hiller
Copy link
Owner

fabian-hiller commented Oct 27, 2024

Are you interested in creating a PR that implements the action and adds tests? This action is very similar to other actions like email or decimal. You could just copy one of them and use it as a template.

@JacKyDev
Copy link

If the questioner doesn’t want to, I’d do it. However, I’d only be able to manage it next week.

I wanted to dive deeper into the valibot code anyway. But only if you agree, as the questioner hasn’t responded yet.

@paksa92
Copy link

paksa92 commented Nov 1, 2024

I implemented it: #907

@fabian-hiller
Copy link
Owner

I am focusing on our v1 release at the moment. In the meantime, I recommend using the regex with our regex action as a workaround.

@fabian-hiller fabian-hiller added the workaround Workaround fixes problem label Nov 1, 2024
@JacKyDev
Copy link

JacKyDev commented Nov 1, 2024

@fabian-hiller : A quick general question about PRs since I’m looking at one right now. Should the .mdx files for the website, like menu.md and properties.ts, also be updated? Otherwise, it would mean the features are there but not visible anywhere (like in the docs).

@fabian-hiller
Copy link
Owner

Yes, but I can also take care of the details because I know it can be hard to understand all the connections.

@tats-u
Copy link

tats-u commented Nov 11, 2024

image
https://makenowjust-labs.github.io/recheck/playground/

/^((?!-)[A-Za-z0-9-]{1,63}(?<!-).)+[A-Za-z]{2,}$/.test('0' + '0-'.repeat(30) + '\x00')

took about 10s to yield false. The attack string's length is just 62.

@paksa92
Copy link

paksa92 commented Nov 11, 2024

@tats-u we agreed on this final regex pattern: /^(?=.{1,253}$)(?!-)([a-z0-9-]{1,63}(?<!-)\.)+[a-z]{2,63}$/iu in #907.

Which is safe according to the tool you provided:
image

@tats-u
Copy link

tats-u commented Nov 11, 2024

I see. That's a good news. We don't have to care about ReDoS now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request workaround Workaround fixes problem
Projects
None yet
Development

No branches or pull requests

5 participants