Req #55574 [Opn->Wfx]: apache2filter code does not do syntax highlighting
| From: | kalle@php.net | Date: | Wed, 18 Oct 2017 18:22:30 +0000 |
| Subject: | Req #55574 [Opn->Wfx]: apache2filter code does not do syntax highlighting | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211772@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55574&edit=1
ID: 55574
Updated by: kalle@php.net
Reported by: php at jdc dot parodius dot com
Summary: apache2filter code does not do syntax highlighting
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Apache2 related
Operating System: FreeBSD 8.2-STABLE
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
With the apache2filter SAPI gone in 7.0, I'm gonna close this as it is no longer relevant
Previous Comments:
------------------------------------------------------------------------
[2011-09-03 00:40:34] php at jdc dot parodius dot com
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 this bug report at https://bugs.php.net/bug.php?id=55574&edit=1