Index: branches/1.1dev/lib/App.inc.php
===================================================================
--- branches/1.1dev/lib/App.inc.php	(revision 292)
+++ branches/1.1dev/lib/App.inc.php	(revision 308)
@@ -693,5 +693,5 @@
         }
     }
-    return $dolookup ? gethostbyaddr($ip) : $ip;
+    return $dolookup && '' != $ip ? gethostbyaddr($ip) : $ip;
 }
 
Index: branches/1.1dev/lib/FormValidator.inc.php
===================================================================
--- branches/1.1dev/lib/FormValidator.inc.php	(revision 292)
+++ branches/1.1dev/lib/FormValidator.inc.php	(revision 308)
@@ -347,10 +347,9 @@
      *
      * @param  string  $form_name       The name of the incoming form variable
-     * @param  boolean $allow_fullname  Allow the use of rfc822 expanded email address with comment: Quinn Commie <quinn@strangecode.com>
      *
      * @return bool    true if no errors found, false otherwise
      */
-    function validateEmail($form_name, $allow_fullname=false)
-    {
+    function validateEmail($form_name)
+    {        
         $email = getFormData($form_name);
         if ('' == trim($email)) {
@@ -358,31 +357,45 @@
         }
         
+        $regex = '/^(?:[^,@]*\s+|[^,@]*(<)|)'                           // Display name
+        . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)'    // Local-part
+        . '@'                                                           // @
+        . '((?:(\[)|[A-Z0-9]?)'                                         // Domain, first char
+        . '(?(4)'                                                       // Domain conditional for if first domain char is [
+        . '(?:[0-9]{1,3}\.){3}[0-9]{1,3}\]'                             // TRUE, matches IP address
+        . '|'
+        . '[.-]?(?:[A-Z0-9]+[-.])*(?:[A-Z0-9]+\.)+[A-Z]{2,6}))'         // FALSE, matches domain name
+        . '(?(1)'                                                       // Comment conditional for if initial < exists
+        . '(?:>\s*|>\s+\([^,@]+\)\s*)'                                  // TRUE, ensure ending >
+        . '|'
+        . '(?:|\s*|\s+\([^,@]+\)\s*))$/i';
+        
         // Test email address format.
-        if ($allow_fullname) {
-            if (!$this->checkRegex($form_name, '/^[\w\s]*<?php[A-Za-z0-9._-]{1,}\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5}>?$/i', true, sprintf(_("<strong>%s</strong> is not a valid email address."), $email))) {
-                logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
-                return false;
-            }
-        } else {
-            if (!$this->checkRegex($form_name, '/^[A-Za-z0-9._-]{1,}\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5}$/i', true, sprintf(_("<strong>%s</strong> is not a valid email address."), $email))) {
-                logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
-                return false;
-            }
-        }
+        if (!preg_match($regex, getFormData($form_name), $e_parts)) {
+            $this->addError($form_name, sprintf(_("The email address <strong>%s</strong> is formatted incorrectly."), oTxt(getFormData($form_name))), MSG_ERR, __FILE__, __LINE__);
+            logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
+        }
+        
+        // We have a match! Here are the captured subpatterns, on which further tests are run.
+        // The part before the @. 
+        $local = $e_parts[2];
+
+        // The part after the @. 
+        // If domain is an IP [XXX.XXX.XXX.XXX] strip off the brackets.
+        $domain = $e_parts[3]{0} == '[' ? mb_substr($e_parts[3], 1, -1) : $e_parts[3];
         
         // Test length.
-        if (!$this->stringLength($form_name, 0, 128, sprintf(_("<strong>Email address</strong> must contain less than 128 characters."), $email))) {
-            logMsg(sprintf('The email address %s must contain less than 128 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-        
-        // Check domain exists and has valid MX record.
-        preg_match('/^[\w\s]*<?php[A-Za-z0-9._-]{1,}\@([A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/i', $email, $matches);
-        if (!empty($matches[1])) {
-            if (!checkdnsrr($matches[1] . '.', 'MX') && gethostbyname($matches[1]) == $matches[1]) {
-                $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email domain name"), $matches[1]));
-                logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $matches[1]), LOG_DEBUG, __FILE__, __LINE__);
-                return false;
-            }
+        if (mb_strlen($local) > 64 || mb_strlen($domain) > 191) {
+            $this->addError($form_name, sprintf(_("The email address <strong>%s</strong> is too long."), oTxt(getFormData($form_name))), MSG_ERR, __FILE__, __LINE__);
+            logMsg(sprintf('The email address %s is too long.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
+        }
+        
+        // Check domain exists: It's a domain if ip2long fails; Checkdnsrr ensures a MX record exists; Gethostbyname() ensures the domain exists.
+        // Compare ip2long twice for php4 backwards compat.
+        if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
+            $this->addError($form_name, sprintf(_("The email address <em>%s</em> does not have a valid domain name."), oTxt(getFormData($form_name))), MSG_ERR, __FILE__, __LINE__);
+            logMsg(sprintf('The email address %s does not have a valid domain name.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
         }
         
Index: branches/1.1dev/lib/TemplateGlue.inc.php
===================================================================
--- branches/1.1dev/lib/TemplateGlue.inc.php	(revision 292)
+++ branches/1.1dev/lib/TemplateGlue.inc.php	(revision 308)
@@ -169,9 +169,9 @@
             if ('allone' == $flag) {
                 // Print a cell with multidimentioal array checkboxes.
-                ?><td><label><input type="checkbox" name="dbcol[<?php echo $db_col; ?>][<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
+                ?><td><label class="normal"><input type="checkbox" name="dbcol[<?php echo $db_col; ?>][<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
                 <?php
              } else {
                 // Print a cell with basic named checkboxes.
-                ?><td><label><input type="checkbox" name="<?php echo $db_col; ?>[<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
+                ?><td><label class="normal"><input type="checkbox" name="<?php echo $db_col; ?>[<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
                 <?php
             }
@@ -248,5 +248,5 @@
             }
             // Print a cell with basic named checkboxes.
-            ?><td><label><input type="radio" name="<?php echo $db_col; ?>" value="<?php echo $item ?>"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
+            ?><td><label class="normal"><input type="radio" name="<?php echo $db_col; ?>" value="<?php echo $item ?>"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
             <?php
         }
