From 9b76b3ae45cf8797cd2c7ded7915002c20f20684 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 9 Jul 2022 00:37:55 +0530 Subject: [PATCH] `phpinfo` HTML Output: Make module title names clickable and link to the URL fragment Each section of `phpinfo` is titled with an `

NAME

` tag. While the `name=module_NAME` attribute allows linking to that section using a URL fragment (e.g `info.php#module_NAME`), it lacks discoverability because the `` tag does not contain an `href` attribute. This is also highlighted in accessibility scans (in Firefox for instance). This adds a link to the `` tag that links to the URL fragment, fixing the accessibility remark and improving the discoverability of the clickable section titles. Also contains minor CSS changes to account for the dark theme CSS. --- ext/phar/tests/phpinfo_004.phpt | 4 ++-- ext/standard/css.c | 1 + ext/standard/info.c | 2 +- .../general_functions/phpinfo-header-anchors.phpt | 11 +++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 ext/standard/tests/general_functions/phpinfo-header-anchors.phpt diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt index dab8bbba0326b..b893c573c3d67 100644 --- a/ext/phar/tests/phpinfo_004.phpt +++ b/ext/phar/tests/phpinfo_004.phpt @@ -25,7 +25,7 @@ phpinfo(INFO_MODULES); ===DONE=== --EXPECTF-- %a -

Phar

+

Phar

@@ -47,7 +47,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar full
Phar: PHP Archive supportenabled
Phar API version 1.1.1
phar.require_hashOffOff
%a -

Phar

+

Phar

diff --git a/ext/standard/css.c b/ext/standard/css.c index 757236c371739..2f9244def2885 100644 --- a/ext/standard/css.c +++ b/ext/standard/css.c @@ -31,6 +31,7 @@ PHPAPI ZEND_COLD void php_info_print_css(void) /* {{{ */ PUTS("th {position: sticky; top: 0; background: inherit;}\n"); PUTS("h1 {font-size: 150%;}\n"); PUTS("h2 {font-size: 125%;}\n"); + PUTS("h2 a:link, h2 a:visited{color: inherit; background: inherit;}\n"); PUTS(".p {text-align: left;}\n"); PUTS(".e {background-color: #ccf; width: 300px; font-weight: bold;}\n"); PUTS(".h {background-color: #99c; font-weight: bold;}\n"); diff --git a/ext/standard/info.c b/ext/standard/info.c index a7efe770f06e4..afdf229ecad6b 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -137,7 +137,7 @@ PHPAPI ZEND_COLD void php_info_print_module(zend_module_entry *zend_module) /* { zend_string *url_name = php_url_encode(zend_module->name, strlen(zend_module->name)); zend_str_tolower(ZSTR_VAL(url_name), ZSTR_LEN(url_name)); - php_info_printf("

%s

\n", ZSTR_VAL(url_name), zend_module->name); + php_info_printf("

%s

\n", ZSTR_VAL(url_name), ZSTR_VAL(url_name), zend_module->name); efree(url_name); } else { diff --git a/ext/standard/tests/general_functions/phpinfo-header-anchors.phpt b/ext/standard/tests/general_functions/phpinfo-header-anchors.phpt new file mode 100644 index 0000000000000..0f0f07f4fe2c0 --- /dev/null +++ b/ext/standard/tests/general_functions/phpinfo-header-anchors.phpt @@ -0,0 +1,11 @@ +--TEST-- +phpinfo() with clickable anchor tags +--CGI-- +--FILE-- + +--EXPECTF-- +%a +

Core

+%a
Phar: PHP Archive supportenabled
Phar API version 1.1.1