function profile2_regpath_url_validator in Profile2 Registration Path 7
Same name and namespace in other branches
- 7.2 profile2_regpath.admin.inc \profile2_regpath_url_validator()
Verifies the syntax of the given URL.
Parameters
string $url: A string containing a URL.
Return value
boolean TRUE if the URL is in a valid format, and FALSE if it isn't.
1 call to profile2_regpath_url_validator()
- profile2_regpath_validate_settings in ./
profile2_regpath.admin.inc - Validate profile settings form values.
File
- ./
profile2_regpath.admin.inc, line 201 - Modifications to administrative forms.
Code
function profile2_regpath_url_validator($url) {
$LINK_ICHARS_DOMAIN = (string) html_entity_decode(implode("", array(
// æ
"æ",
// Æ
"Æ",
// ø
"ø",
// Ø
"Ø",
// å
"å",
// Å
"Å",
// ä
"ä",
// Ä
"Ä",
// ö
"ö",
// Ö
"Ö",
// ü
"ü",
// Ü
"Ü",
// Ñ
"Ñ",
// ñ
"ñ",
)), ENT_QUOTES, 'UTF-8');
$LINK_ICHARS = $LINK_ICHARS_DOMAIN . (string) html_entity_decode(implode("", array(
// ß
"ß",
)), ENT_QUOTES, 'UTF-8');
// Pattern specific to internal links.
$internal_pattern = "/^(?:[a-z0-9" . $LINK_ICHARS . "_\\-+\\[\\]]+)";
$directories = "(?:\\/[a-z0-9" . $LINK_ICHARS . "_\\-\\.~+%=&,\$'!():;*@\\[\\]]*)*";
// Yes, four backslashes == a single backslash.
$query = "(?:\\/?\\?([?a-z0-9" . $LINK_ICHARS . "+_|\\-\\.\\/\\\\%=&,\$'():;*@\\[\\]{} ]*))";
$anchor = "(?:#[a-z0-9" . $LINK_ICHARS . "_\\-\\.~+%=&,\$'():;*@\\[\\]\\/\\?]*)";
// The rest of the path for a standard URL.
$end = $directories . '?' . $query . '?' . $anchor . '?' . '$/i';
if (preg_match($internal_pattern . $end, $url)) {
return TRUE;
}
}