php / php/php-src

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

Open
#7,781 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature SAPI: cli_server Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the documented php -S 0.0..0:8080 command and inspect the built-in web server's error-reporting path. Done means the invalid-address warning remains readable in the terminal without emitting HTML tags, while the existing failure message is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.