Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义端口错误getUrlPrefix() #338

Closed
ghost opened this issue Nov 14, 2014 · 2 comments
Closed

自定义端口错误getUrlPrefix() #338

ghost opened this issue Nov 14, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 14, 2014

build(1.0.14.10.10.-release)/var/Typecho/Request.php
line 218

  • 复现条件:
  • 自定义端口,(非80,443)
  • 现象:
    所有链接地址端口重复,如http://www.xxx.com:3333:3333/path/to/some
  • 原因:
    $_SERVER['HTTP_HOST'] 取值包含端口,值为:www.xxx.com:3333
    $_SERVER['SERVER_NAME'] 取值不带端口.值为:www.xxx.com

$_SERVER['HTTP_HOST'] 有值时,且端口不为80,443时,加粗部分条件成立,那么将导致端口重复。
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'])
. (in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT']);

public static function getUrlPrefix()
    {
        if (empty(self::$_urlPrefix)) {
            self::$_urlPrefix = (self::isSecure() ? 'https' : 'http') 
                . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'])
                . (in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT']);
        }

        return self::$_urlPrefix;
    }
@joyqi
Copy link
Member

joyqi commented Nov 14, 2014

是的,这个bug我们已经修复了,但是还没有发布到正式版里,你可以使用开发版看到它的修正

@joyqi joyqi closed this as completed Nov 14, 2014
@ghost
Copy link
Author

ghost commented Nov 14, 2014

OK~下次可需要先看看开发版了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant