From:
Operating system: FreeBSD 8.2-STABLE
PHP version: 5.3.8
Package: Apache2 related
Bug Type: Feature/Change Request
Bug description:apache2filter code does not do syntax highlighting
Description:
------------
The PHP experimental apache2filter code (e.g. --with-apxs2filter) does not
properly handle syntax highlighting requests, despite the documentation
stating such should work. Taken from sapi/apache2filter/README:
36 At the end of conf/httpd.conf, add:
37
38 AddType application/x-httpd-php .php
39
40 If you would like to enable source code highlighting
functionality add:
41
42 AddType application/x-httpd-php-source .phps
sapi/apache2filter/sapi_apache2.c has the following code:
670 static void php_insert_filter(request_rec *r)
671 {
672 int content_type_len = strlen("application/x-httpd-php");
673
674 if (r->content_type && !strncmp(r->content_type,
"application/x-httpd-php", content_type_len-1)) {
675 if (r->content_type[content_type_len] == '\0' ||
!strncmp(r->content_type+content_type_len, "-source", sizeo
f("-source"))) {
676 php_add_filter(r, r->output_filters);
677 php_add_filter(r, r->input_filters);
678 }
679 }
680 }
Translated to English, all this does is cause Content-Type
application/x-httpd-source documents to be parsed and run, not sent through
the syntax highlighter. Testing a fetch of a .phps document confirms this;
the code gets run, with no output. This is incorrect behaviour when
compared to what the README states.
If you compare the above code to that of, say,
sapi/apache2handler/sapi_apache2.c, you will find that the handler (not
filter) code there does extra work to make sure such requests get shoved
through the syntax highlighter.
Solution:
Please pick one ((a) is obviously preferred):
a) improve sapi/apache2filter/sapi_apache2.c to properly send
application/x-httpd-source requests through the highlighter,
b) update the README to reflect that source highlighting does not work with
apxs2filter.
Sub-items that should be addressed while I'm here:
1) PHP Bug 40499 should be closed as invalid; there is no "PHP-highlight"
filter. I have no idea where the user got that idea. Not to mention,
Set{Input,Output}Filter directives should not be used when
--with-apxs2filter is used; all people need, truly, is AddType directives.
Users/admins have to read the source to understand that fact. I wish this
was made more apparent.
https://bugs.php.net/bug.php?id=40499
2) There is no mention of --with-apxs2filter in the PHP configure flags
documentation. It doesn't matter if the support is experimental -- it
should be documented. http://www.php.net/manual/en/configure.about.php
Test script:
---------------
Not needed; see description.
Expected result:
----------------
Users/administrators expect that when apxs2filter is used, per the README,
that .phps documents should render as syntax highlighted.
Actual result:
--------------
.phps documents are actually executed/parsed as code.
--
Edit bug report at https://bugs.php.net/bug.php?id=55574&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55574&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55574&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55574&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55574&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55574&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55574&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55574&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55574&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55574&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55574&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55574&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55574&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55574&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55574&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55574&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55574&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55574&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55574&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55574&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55574&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55574&r=mysqlcfg