mirror of
https://github.com/spatie/dnsrecords.io.git
synced 2026-04-27 08:25:57 +03:00
[GH-ISSUE #4] Filter out invalid characters server side #3
Labels
No labels
bug
good first issue
help wanted
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/dnsrecords.io#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @freekmurze on GitHub (Oct 27, 2017).
Original GitHub issue: https://github.com/spatie/dnsrecords.io/issues/4
Originally assigned to: @freekmurze on GitHub.
Only alphanumeric characters and a
.should be accepted. Let's just filter those out.@brendt commented on GitHub (Oct 27, 2017):
We're going to need a little more than just alphanumeric characters and a
., eg.-and_.This post (which is based on the URI spec) lists a lot more: https://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid/1547940#1547940
All of these are valid URI characters.
?eg. doesn't make sense in a domain name, but people could still paste a whole URL, which should be able to be parsed. I think PHP'sparse_urlmight actually be a good solution, because than you shouldn't worry about parsing the input at all. If it's a valid URL,parse_url($url, PHP_URL_HOST)will return the host, otherwise it will return null.http://orhttps://should be present though.@bbashy commented on GitHub (Oct 27, 2017):
@brendt It removes those https://github.com/spatie/dnsrecords.io/blob/master/app/Http/Controllers/HomeController.php#L81
@willemvb commented on GitHub (Oct 27, 2017):
Side note: what with top level domains?
Eg.
.as first character might need some extra attention:becurrently works.currently works.befails@brendt commented on GitHub (Oct 27, 2017):
@bbashy that's perfect, no?
@bbashy commented on GitHub (Oct 27, 2017):
@brendt Yeah something like that is fine apart from you need to remove http(s):// since
digdoesn't accept it.@bbashy commented on GitHub (Oct 27, 2017):
Not like #9
@brendt commented on GitHub (Oct 27, 2017):
@bbashy
parse_urlalso automatically filters outhttp://andhttps://. You just have to make sure the protocol is there to be able to parse it: https://3v4l.org/8nqnA@brendt commented on GitHub (Oct 27, 2017):
Also @willemvb
parse_urladdresses that issue: https://3v4l.org/CI9pp@bbashy commented on GitHub (Oct 27, 2017):
Ah yeah, of course!
@brendt commented on GitHub (Oct 27, 2017):
@willemvb I was wrong about
parse_urladdressing thebeissue.To be complete:
.beis not a valid domain, but for better user experience, it should work and be filtered.be.is a valid domain, but doesn't work withparse_url..also doesn't work, but is a valid domain (the root domain). This exception should also work.So these three exceptions should be handled before
parse_url; but maybe thanparse_urlmight not be needed at all.@freekmurze commented on GitHub (Oct 27, 2017):
Fixed in #9