News for hackers. Stuff that matters.
Re:In search of the perfect URL validation regex by mdavidn on Sunday June 22, 2014 @07:04PM (#7929518)
Use a standard URI parser to break this problem into smaller parts. Let a modern URI library worry about arcane details like spaces, fragments, userinfo, IPv6 hosts, etc.

   uri = URI.parse(target).normalize
   uri.absolute? or raise 'URI not absolute'
   %w[ http https ftp ].include?(uri.scheme) or raise 'Unsupported URI scheme'
   # Etc
Re:In search of the perfect URL validation regex by mathias on Monday June 23, 2014 @03:01AM (#7930595)
That was not an option in this case, as the goal is to validate URLs entered as user input and blacklist certain URL constructs even though they’re technically valid.
Re:In search of the perfect URL validation regex by mdavidn on Monday June 23, 2014 @11:29AM (#7932453)
So check if uri.host matches your blacklist.
Re:In search of the perfect URL validation regex by droope on Sunday June 22, 2014 @08:00PM (#7929612)
It'd be interesting to look at URI.parse's source code.
Re:In search of the perfect URL validation regex by mdavidn on Monday June 23, 2014 @11:33AM (#7932479)
It does match a regular expression internally.

https://github.com/ruby/ruby/blob/trunk/lib/uri/rfc2396_pars...