Changeset 15911
- Timestamp:
- 10/22/2010 10:27:35 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-http.php
r15362 r15911 541 541 * file and this will only allow localhost and your blog to make requests. The constant 542 542 * WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the 543 * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow. 543 * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains 544 * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted. 544 545 * 545 546 * @since 2.8.0 546 547 * @link http://core.trac.wordpress.org/ticket/8927 Allow preventing external requests. 548 * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS 547 549 * 548 550 * @param string $uri URI of url. … … 578 580 579 581 static $accessible_hosts; 580 if ( null == $accessible_hosts ) 582 static $wildcard_regex = false; 583 if ( null == $accessible_hosts ) { 581 584 $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS); 582 585 583 return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it. 586 if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) { 587 $wildcard_regex = array(); 588 foreach ( $accessible_hosts as $host ) 589 $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/')); 590 $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; 591 } 592 } 593 594 if ( !empty($wildcard_regex) ) 595 return !preg_match($wildcard_regex, $check['host']); 596 else 597 return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it. 598 599 600 584 601 } 585 602 } … … 1479 1496 * <li>WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy. 1480 1497 * You do not need to have localhost and the blog host in this list, because they will not be passed 1481 * through the proxy. The list should be presented in a comma separated list </li>1498 * through the proxy. The list should be presented in a comma separated list, wildcards using * are supported, eg. *.wordpress.org</li> 1482 1499 * </ol> 1483 1500 * … … 1486 1503 * define('WP_PROXY_HOST', '192.168.84.101'); 1487 1504 * define('WP_PROXY_PORT', '8080'); 1488 * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com ');1505 * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com, *.wordpress.org'); 1489 1506 * </code> 1490 1507 * 1491 1508 * @link http://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress. 1509 * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS 1492 1510 * @since 2.8 1493 1511 */ … … 1629 1647 1630 1648 static $bypass_hosts; 1631 if ( null == $bypass_hosts ) 1649 static $wildcard_regex = false; 1650 if ( null == $bypass_hosts ) { 1632 1651 $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS); 1633 1652 1634 return !in_array( $check['host'], $bypass_hosts ); 1653 if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) { 1654 $wildcard_regex = array(); 1655 foreach ( $bypass_hosts as $host ) 1656 $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/')); 1657 $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; 1658 } 1659 } 1660 1661 if ( !empty($wildcard_regex) ) 1662 return !preg_match($wildcard_regex, $check['host']); 1663 else 1664 return !in_array( $check['host'], $bypass_hosts ); 1635 1665 } 1636 1666 }
Note: See TracChangeset
for help on using the changeset viewer.