php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55574 apache2filter code does not do syntax highlighting
Submitted: 2011-09-03 00:40 UTC Modified: 2017-10-18 18:22 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at jdc dot parodius dot com Assigned:
Status: Wont fix Package: Apache2 related
PHP Version: 5.3.8 OS: FreeBSD 8.2-STABLE
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-09-03 00:40 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-18 18:22 UTC] kalle@php.net
-Status: Open +Status: Wont fix
 [2017-10-18 18:22 UTC] kalle@php.net
With the apache2filter SAPI gone in 7.0, I'm gonna close this as it is no longer relevant
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 16:01:26 2019 UTC