php / php/php-src

Built-in web server prints HTML tags in terminal when address is wrong

未关闭
#7,781 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Feature SAPI: cli_server Status: Verified
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
103

描述

Description

I tried to start the built-in web server, but I mistyped the address and then the PHP cli printed HTML tags in the terminal.

- php -S 0.0.0.0:8080
+ php -S 0.0..0:8080

Resulted in this output:

$ php -S 0.0..0:8080
[Wed Dec 15 11:54:39 2021] PHP Warning:  Unknown: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known in Unknown on line 0
<br />
<b>Warning</b>:  Unknown: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known in <b>Unknown</b> on line <b>0</b><br />
[Wed Dec 15 11:54:39 2021] Failed to listen on 0.0..0:8080 (reason: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known)

But I expected this output instead:

$ php -S 0.0..0:8080
[Wed Dec 15 12:01:43 2021] PHP Warning:  Unknown: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known in Unknown on line 0
[Wed Dec 15 12:01:43 2021] Failed to listen on 0.0..0:8080 (reason: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known)

PHP version:

PHP 8.1.0 (cli) (built: Nov 25 2021 20:48:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
    with blackfire v1.72.0~linux-x64-non_zts81, https://blackfire.io, by Blackfire
PHP Version

8.1.0

Operating System

Debian Bookworm

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用文档中的 php -S 0.0..0:8080 命令重现该问题,并检查内置 Web 服务器的错误报告路径。完成的标准是:无效地址警告在终端中仍然清晰可读,且不会输出 HTML 标签,同时保留现有的失败消息。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
cli
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。