Changeset 676 for trunk/lib


Ignore:
Timestamp:
May 3, 2019 2:43:15 AM (5 years ago)
Author:
anonymous
Message:

Update admins.php. Fix $safe_http_host

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r671 r676  
    479479         */
    480480
    481         $safe_http_host = preg_replace('/[^a-z\d.:-]/', '', getenv('HTTP_HOST'));
     481        // To get a safe hostname, remove host port and invalid hostname characters.
     482        $safe_http_host = preg_replace('/[^a-z\d.:-]/', '', strtok(getenv('HTTP_HOST'), ':'));
    482483        if ('' != $safe_http_host && '' == $this->getParam('site_hostname')) {
    483484            $this->setParam(array('site_hostname' => $safe_http_host));
     
    487488        // and is used whenever a URL need be used to the current site.
    488489        // Not available on CLI scripts obviously.
    489         if ($safe_http_host && '' == $this->getParam('site_url')) {
     490        if ('' != $safe_http_host && '' == $this->getParam('site_url')) {
    490491            $this->setParam(array('site_url' => sprintf('%s://%s', (getenv('HTTPS') ? 'https' : 'http'), $safe_http_host)));
    491492        }
Note: See TracChangeset for help on using the changeset viewer.