Commit 951762a1 authored by Nathan Haug's avatar Nathan Haug
Browse files

Adding user:password@ notation to link validation. #137588.

parent 5f09d06a
......@@ -299,7 +299,7 @@ function link_widget($op, &$node, $field, &$node_field) {
$form[$field['field_name']]['more-url'] = array(
'#type' => 'hidden',
'#value' => url('link/widget/js/' . $field['type_name'] . '/' . $field['field_name'], NULL, NULL, TRUE),
'#attributes' => array('class' => 'more'),
'#attributes' => array('class' => 'more-links'),
'#id' => str_replace('_', '-', $field['field_name']) . '-more-url',
);
......@@ -773,13 +773,14 @@ function link_validate_url($text) {
$allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
$protocol = '((' . implode("|", $allowed_protocols) . '):\/\/)';
$authentication = '([a-z0-9]+(:[a-z0-9]+)?@)';
$domain = '(([a-z0-9]([a-z0-9\-_\[\]]*\.)+)('. LINK_DOMAINS .'|[a-z]{2}))';
$ipv4 = '([0-9]{1,3}(\.[0-9]{1,3}){3})';
$ipv6 = '([0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7})';
$port = '(:([0-9]{1,4}))';
// Pattern specific to eternal links
$external_pattern = '/^' . $protocol . '?'. '(' . $domain . '|' . $ipv4 . '|' . $ipv6 . ' |localhost)' . $port . '?';
$external_pattern = '/^' . $protocol . '?'. $authentication . '?' . '(' . $domain . '|' . $ipv4 . '|' . $ipv6 . ' |localhost)' . $port . '?';
// Pattern specific to internal links
$internal_pattern = "/^([a-z0-9_\-+\[\]]+)";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment