Index: link.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/link/link.module,v
retrieving revision 1.16
diff -u -r1.16 link.module
--- link.module	21 Sep 2006 04:52:01 -0000	1.16
+++ link.module	3 Oct 2006 22:34:30 -0000
@@ -185,12 +185,8 @@
     case 'validate':
       foreach($node_field as $delta => $value) {
         if ($value['value']['link']) {
-          // Validate the link
-          if (!link_validate_link($value['value']['link'])) {
-            form_set_error($field['field_name'] .']['. $delta. '][value][link', t('Not a valid URL.'));
-          }
           // Require a title for the link if necessary
-          elseif ($field['title'] == 'required' && strlen(trim($value['value']['title'])) == 0) {
+          if ($field['title'] == 'required' && strlen(trim($value['value']['title'])) == 0) {
             form_set_error($field['field_name'] .']['. $delta. '][value][title', t('Titles are required for all links.'));
           }
         }
@@ -278,11 +274,11 @@
   }
   // Build the link with a title
   if (strlen(trim($value['title']))) {
-    $output = l($value['title'],link_cleanup_url($value['link']),$attributes);
+    $output = l($value['title'],$value['link'],$attributes);
   }
   // Build the link with the URL as the title (max 80 characters)
   else {
-    $output = l(strlen($value['link']) > 80 ? substr($value['link'],0,80)."..." : $value['link'],link_cleanup_url($value['link']),$attributes);
+    $output = l(strlen($value['link']) > 80 ? substr($value['link'],0,80)."..." : $value['link'],$value['link'],$attributes);
   }
   return $output;
 }
@@ -353,66 +349,3 @@
   return $tables;
 }
 
-/**
- * Forms a valid URL if possible from an entered address.
- * Trims whitespace and automatically adds an http:// to addresses without a protocol specified
- *
- * @param string $url
- * @param string $protocol The protocol to be prepended to the url if one is not specified
- */
-function link_cleanup_url ($url, $protocol = "http") {
-  $url = trim($url);
-  
-  // Check if there is no protocol specified
-  $protocol_match = preg_match("/^([a-z0-9][a-z0-9\.\-_]*:\/\/)/i",$url);
-  if (empty($protocol_match)) {
-    // But should it be? Add an automatic http:// if it starts with a domain name
-    $domain_match = preg_match('/^(([a-z0-9]([a-z0-9\-_]*\.)+)(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|[a-z]{2}))/i',$url);
-    if (!empty($domain_match)) {
-      $url = $protocol."://".$url;
-    }
-  }
-  
-  return $url;
-}
-
-/**
- * A lenient verification for URLs. Accepts all URLs following RFC 1738 standard for URL formation.  
- *
- * @param string $text
- * @return mixed Returns boolean FALSE if the URL is not valid. On success, returns an object with
- * the following attributes: protocol, hostname, ip, and port.
- */
-function link_validate_link($text) {
-  if (!preg_match(
-    // protocol
-    '/^([a-z0-9][a-z0-9\.\-_]*:\/\/)?'.
-  '('.
-    // domains
-      '(([a-z0-9]([a-z0-9\-_]*\.)+)(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|[a-z]{2}))'.
-      // OR ip addresses
-      '|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'.
-  ')'.
-    // port number
-    '(:([0-9]{1,4}))?'.
-    // the rest of the path
-    "(\/[a-z0-9_\-\.~+%=&,$'():;*@]+)*".
-    // anchors
-    "\/?#?[a-z0-9_\-\.~+%=&,$'():;*@]*".
-    // the query string
-    "(\/?\?[a-z0-9+_\-\.\/%=&,$'():;*@]*)?".
-    // forward slash 0 or 1 times
-    '(\/)?'.
-    // end of the expression, case insensitive
-    '$/i', $text, $m)) {
-    return false;
-  }
-  else {
-    $url = new stdClass();
-    $url->protocol = $m[2];
-    $url->hostname = strtolower($m[5]).strtolower($m[7]);
-    $url->ip = $m[8];
-    $url->port = $m[10];
-    return $url;
-  }
-}
