function feeds_valid_url in Feeds 6
Same name and namespace in other branches
- 8.2 feeds.module \feeds_valid_url()
- 7.2 feeds.module \feeds_valid_url()
Copy of valid_url() that supports the webcal scheme.
@todo Replace with valid_url() when http://drupal.org/node/295021 is fixed.
See also
valid_url().
2 calls to feeds_valid_url()
- FeedsHTTPFetcher::sourceFormValidate in plugins/
FeedsHTTPFetcher.inc - Override parent::sourceFormValidate().
- FeedsUnitTestCase::testFeedsValidURL in tests/
feeds.test - Test valid absolute urls.
File
- ./
feeds.module, line 958 - Feeds - basic API functions and hook implementations.
Code
function feeds_valid_url($url, $absolute = FALSE) {
if ($absolute) {
return (bool) preg_match("\n /^ # Start at the beginning of the text\n (?:ftp|https?|feed|webcal):\\/\\/ # Look for ftp, http, https, feed or webcal schemes\n (?: # Userinfo (optional) which is typically\n (?:(?:[\\w\\.\\-\\+!\$&'\\(\\)*\\+,;=]|%[0-9a-f]{2})+:)* # a username or a username and password\n (?:[\\w\\.\\-\\+%!\$&'\\(\\)*\\+,;=]|%[0-9a-f]{2})+@ # combination\n )?\n (?:\n (?:[a-z0-9\\-\\.]|%[0-9a-f]{2})+ # A domain name or a IPv4 address\n |(?:\\[(?:[0-9a-f]{0,4}:)*(?:[0-9a-f]{0,4})\\]) # or a well formed IPv6 address\n )\n (?::[0-9]+)? # Server port number (optional)\n (?:[\\/|\\?]\n (?:[|\\w#!:\\.\\?\\+=&@\$'~*,;\\/\\(\\)\\[\\]\\-]|%[0-9a-f]{2}) # The path and query (optional)\n *)?\n \$/xi", $url);
}
else {
return (bool) preg_match("/^(?:[\\w#!:\\.\\?\\+=&@\$'~*,;\\/\\(\\)\\[\\]\\-]|%[0-9a-f]{2})+\$/i", $url);
}
}