Commit 115e37c3 authored by John C Fiala's avatar John C Fiala
Browse files

bug report #495834 by jcfiala:Turns out the Eszett character is not allowed in...

bug report #495834 by jcfiala:Turns out the Eszett character is not allowed in domain names, so changed validation to prevent it from being used there.
parent a200e517
......@@ -828,7 +828,7 @@ function _link_code2utf($num) {
* the following attributes: protocol, hostname, ip, and port.
*/
function link_validate_url($text) {
$LINK_ICHARS = (string) _link_html_entity_decode(implode("", array(
$LINK_ICHARS_DOMAIN = (string) _link_html_entity_decode(implode("", array(
"æ", // æ
"Æ", // Æ
"ø", // ø
......@@ -841,15 +841,18 @@ function link_validate_url($text) {
"Ö", // Ö
"ü", // ü
"Ü", // Ü
"ß", // ß
"Ñ", // Ñ
"ñ", // ñ
)), ENT_QUOTES, 'UTF-8');
$LINK_ICHARS = $LINK_ICHARS_DOMAIN . (string) _link_html_entity_decode(implode("", array(
"ß", // ß
)), ENT_QUOTES, 'UTF-8');
$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%' . $LINK_ICHARS . ']+(:[a-z0-9%'. $LINK_ICHARS . '!]*)?)?@)';
$domain = '(([a-z0-9' . $LINK_ICHARS . ']([a-z0-9'. $LINK_ICHARS . '\-_\[\]])*)(\.(([a-z0-9' . $LINK_ICHARS . '\-_\[\]])+\.)*('. LINK_DOMAINS .'|[a-z]{2}))?)';
$domain = '(([a-z0-9' . $LINK_ICHARS_DOMAIN . ']([a-z0-9'. $LINK_ICHARS_DOMAIN . '\-_\[\]])*)(\.(([a-z0-9' . $LINK_ICHARS_DOMAIN . '\-_\[\]])+\.)*('. 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,5}))';
......
......@@ -330,7 +330,7 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
}
function test_german_b_url() {
$this->link_test_validate_url('http://www.testß.com/');
$this->link_test_validate_url('http://www.test.com/ßstuff');
}
function test_special_n_url() {
......@@ -484,6 +484,7 @@ class LinkValidateUrlLight extends DrupalUnitTestCase {
'//www.example.com/',
'http://25.0.0/', // bad ip!
'http://4827.0.0.2/',
'http://www.testß.com/', // ß not allowed in domain names!
//'http://www.-fudge.com/', // domains can't have sections starting with a dash.
);
foreach ($links as $link) {
......
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