Ticket #17433: 17433.diff
File 17433.diff, 3.2 KB (added by , 13 years ago) |
---|
-
wp-includes/formatting.php
1522 1522 if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { 1523 1523 return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); 1524 1524 } 1525 1526 // If the domain is one word ... let it through if we can do a DNS lookup on the domain 1527 if ( FALSE === strpos($domain, '.') ) { 1528 if ( FALSE !== filter_var(gethostbyname($domain), FILTER_VALIDATE_IP) ) 1529 return apply_filters( 'is_email', $email, $email, null ); 1530 else 1531 return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); 1532 } 1525 1533 1526 1534 // Split the domain into subs 1527 1535 $subs = explode( '.', $domain ); … … 1744 1752 return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); 1745 1753 } 1746 1754 1747 // Split the domain into subs 1748 $subs = explode( '.', $domain ); 1755 // If the domain is one word ... let it through if we can do a DNS lookup on the domain 1756 if ( FALSE === strpos($domain, '.') ) { 1757 $new_domain = preg_replace( '/[^a-z0-9-]+/i', '', $domain ); 1758 if ( !empty($new_domain) && FALSE !== filter_var(gethostbyname($domain), FILTER_VALIDATE_IP) ) 1759 $domain = $new_domain; 1760 else 1761 return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); 1762 } else { 1749 1763 1750 // Assume the domain will have at least two subs 1751 if ( 2 > count( $subs ) ) { 1752 return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); 1753 } 1764 // Split the domain into subs 1765 $subs = explode( '.', $domain ); 1754 1766 1755 // Create an array that will contain valid subs 1756 $new_subs = array(); 1767 // Assume the domain will have at least two subs 1768 if ( 2 > count( $subs ) ) { 1769 return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); 1770 } 1757 1771 1758 // Loop through each sub 1759 foreach ( $subs as $sub ) { 1760 // Test for leading and trailing hyphens 1761 $sub = trim( $sub, " \t\n\r\0\x0B-" ); 1772 // Create an array that will contain valid subs 1773 $new_subs = array(); 1762 1774 1763 // Test for invalid characters 1764 $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); 1775 // Loop through each sub 1776 foreach ( $subs as $sub ) { 1777 // Test for leading and trailing hyphens 1778 $sub = trim( $sub, " \t\n\r\0\x0B-" ); 1765 1779 1766 // If there's anything left, add it to the valid subs 1767 if ( '' !== $sub ) { 1768 $new_subs[] = $sub; 1780 // Test for invalid characters 1781 $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); 1782 1783 // If there's anything left, add it to the valid subs 1784 if ( '' !== $sub ) { 1785 $new_subs[] = $sub; 1786 } 1769 1787 } 1770 }1771 1788 1772 // If there aren't 2 or more valid subs1773 if ( 2 > count( $new_subs ) ) {1774 return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );1775 }1789 // If there aren't 2 or more valid subs 1790 if ( 2 > count( $new_subs ) ) { 1791 return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); 1792 } 1776 1793 1777 // Join valid subs into the new domain 1778 $domain = join( '.', $new_subs ); 1794 // Join valid subs into the new domain 1795 $domain = join( '.', $new_subs ); 1796 } 1779 1797 1780 1798 // Put the email back together 1781 1799 $email = $local . '@' . $domain;