php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55415 php_info produces invalid anchor names
Submitted: 2011-08-13 09:40 UTC Modified: 2014-12-15 19:37 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: callum at lynxphp dot com Assigned: kalle (profile)
Status: Closed Package: PHP options/info functions
PHP Version: 5.3.6 OS: OS X / Windows
Private report: No CVE-ID: None
 [2011-08-13 09:40 UTC] callum at lynxphp dot com
Description:
------------
A few modules in PHP cause php_info to print invalid anchor names:

<h2><a name="module_Zend Optimizer">Zend Optimizer</a></h2>

The anchor name should not contain a space - this is invalid.


This bug can be replicated on a vanilla install of PHP with Zend Optimiser 
installed.

Test script:
---------------
<?php

phpinfo();


Patches

fix-php_info-anchor-names (last revision 2011-08-13 10:35 UTC by callum at lynxphp dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-13 11:24 UTC] callum at lynxphp dot com
I don't know whether I got the patch file right; I couldn't find any documentation
 [2011-08-15 22:00 UTC] johannes@php.net
There might be other "bad" characters in the name, not only a space. So I think php_url_encode() should be used.

About your patch: Mind that c does no garbage collection so you'd create two memory leaks. A better version might be along the lines of

if (!sapi_module.phpinfo_as_text) {
    int len = 0;
    char *url_name = php_url_encode(zend_module->name, strlen(zend_module->name), &len);
    php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", url_name, zend_module->name);
    efree(url_name);
}

Didn't test it though.
/mind that declarations in
 [2011-08-22 14:27 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: kalle
 [2011-08-22 14:27 UTC] kalle@php.net
I agree Johannes that php_url_encode() should be used, I'm assigning this to myself to try play around with it and see if I can get a working solution for when 5.3.8 is packaged
 [2014-12-14 22:09 UTC] kalle@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ad01fd8b49c6117d5c5fce98871c41781a5c00b9
Log: Fixed bug #55415 (php_info produces invalid anchor names)
 [2014-12-14 22:09 UTC] kalle@php.net
-Status: Assigned +Status: Closed
 [2014-12-14 22:09 UTC] kalle@php.net
Fixed in PHP7.
 [2014-12-15 19:00 UTC] ab@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ad01fd8b49c6117d5c5fce98871c41781a5c00b9
Log: Fixed bug #55415 (php_info produces invalid anchor names)
 [2014-12-15 19:37 UTC] stas@php.net
Note that the patch is broken as is - php_url_encode doesn't even have this signature (it gets 2 params, not 3) but compiles because it misses the definition in url.h due to not including it. This makes it completely broken on any platform where sizeof(int) != sizeof(void *) due to the fact that the compiler assumes php_url_encode returns int.
 [2016-07-20 11:40 UTC] davey@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ad01fd8b49c6117d5c5fce98871c41781a5c00b9
Log: Fixed bug #55415 (php_info produces invalid anchor names)
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jun 01 21:01:25 2020 UTC