Skip to content

Commit ff88701

Browse files
pascalchevreldevnexen
authored andcommitted
Fix GH-17956 Internal dev server 404 page is not responsive
Add a basic viewport html meta tag with responsive mode parameters See: https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag Updated existing tests close GH-17957
1 parent 0097ad8 commit ff88701

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
. Extended --ini to print INI settings changed from the builtin default.
77
(timwolla)
88
. Drop support for -z CLI/CGI flag. (nielsdos)
9+
. Fixed GH-17956 - development server 404 page does not adapt to mobiles.
10+
(pascalchevrel)
911

1012
- COM:
1113
. Fixed property access of PHP objects wrapped in variant. (cmb)

sapi/cli/php_cli_server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ static zend_result php_cli_server_send_error_page(php_cli_server *server, php_cl
20262026
escaped_request_uri = php_escape_html_entities_ex((const unsigned char *) ZSTR_VAL(client->request.request_uri), ZSTR_LEN(client->request.request_uri), 0, ENT_QUOTES, NULL, /* double_encode */ 0, /* quiet */ 0);
20272027

20282028
{
2029-
static const char prologue_template[] = "<!doctype html><html><head><title>%d %s</title>";
2029+
static const char prologue_template[] = "<!doctype html><html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>%d %s</title>";
20302030
php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(strlen(prologue_template) + 3 + strlen(status_string) + 1);
20312031
if (!chunk) {
20322032
goto fail;

sapi/cli/tests/php_cli_server_013.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ X-Powered-By: PHP/%s
131131
Content-Type: text/html; charset=UTF-8
132132
Content-Length: %d
133133

134-
<!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
134+
<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><title>404 Not Found</title><style>AAA</style>
135135
</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/</code> was not found on this server.</p></body></html>
136136
HTTP/1.1 404 Not Found
137137
Host: %s
@@ -141,7 +141,7 @@ X-Powered-By: PHP/%s
141141
Content-Type: text/html; charset=UTF-8
142142
Content-Length: %d
143143

144-
<!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
144+
<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><title>404 Not Found</title><style>AAA</style>
145145
</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/main/style.css</code> was not found on this server.</p></body></html>
146146
HTTP/1.1 404 Not Found
147147
Host: %s
@@ -161,7 +161,7 @@ Content-Type: text/html; charset=UTF-8
161161
Content-Length: %d
162162
Allow: GET, HEAD, POST
163163

164-
<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style>
164+
<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><title>405 Method Not Allowed</title><style>AAA</style>
165165
</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html>
166166
HTTP/1.1 405 Method Not Allowed
167167
Host: %s
@@ -172,7 +172,7 @@ Content-Type: text/html; charset=UTF-8
172172
Content-Length: %d
173173
Allow: GET, HEAD, POST
174174

175-
<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style>
175+
<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><title>405 Method Not Allowed</title><style>AAA</style>
176176
</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html>
177177
HTTP/1.1 405 Method Not Allowed
178178
Host: %s
@@ -183,5 +183,5 @@ Content-Type: text/html; charset=UTF-8
183183
Content-Length: %d
184184
Allow: GET, HEAD, POST
185185

186-
<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style>
186+
<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><title>405 Method Not Allowed</title><style>AAA</style>
187187
</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html>

0 commit comments

Comments
 (0)