Skip to content

Commit

Permalink
Merge pull request #22 from opentechinstitute/is_fqdn
Browse files Browse the repository at this point in the history
Reworked quick fqdn check
  • Loading branch information
critzo committed Sep 13, 2013
2 parents 56f9951 + 444c5a3 commit 57db1bc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions luasrc/commotion_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ function is_email(email)
return tostring(email):match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")
end



function is_hostname(str)
--alphanumeric and hyphen Less than 63 chars
--cannot start or end with a hyphen
Expand All @@ -134,6 +132,17 @@ function is_hostname(str)
end
end

function is_fqdn(str)
-- alphanumeric and hyphen less than 255 chars
-- each label must be less than 63 chars
if #tostring(str) < 255 then
-- Should check that each label is < 63 chars --
return tostring(str):match("^[%w%.%-]+$")
else
return nil
end
end

function is_macaddr(str)
local i,j, _1, _2, _3, _4, _5, _6 = string.find(str, '^(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)$')
if i then return true end
Expand Down Expand Up @@ -189,4 +198,4 @@ url_replacements = {
[">"] = "%3E",
[" "] = "%20",
['"'] = "%22"
}
}

0 comments on commit 57db1bc

Please sign in to comment.