php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59461 php_flag incompatible with apache
Submitted: 2010-10-13 18:37 UTC Modified: 2010-11-21 08:53 UTC
From: martynas at venck dot us Assigned: martynas (profile)
Status: Closed Package: htscanner (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
41 + 39 = ?
Subscribe to this entry?

 
 [2010-10-13 18:37 UTC] martynas at venck dot us
Description:
------------
Htscanner should be a drop-in replacement for mod_php Apache 
scanner;  however currently php_flag behavior is 
incompatible.

I.e., Apache uses the following code to parse php_flag (see 
sapi/apache/mod_php5.c):

static CONST_PREFIX char 
*php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, 
char *arg1, char *arg2, int mode)
{
        char bool_val[2];

        if (!strcasecmp(arg2, "On") || (arg2[0] == '1' && 
arg2[1] == '\0')) {
                bool_val[0] = '1';
        } else {
                bool_val[0] = '0';
        }
        bool_val[1] = 0;
        
        return php_apache_value_handler_ex(cmd, conf, arg1, 
bool_val, mode);
}

Htscanner currently accepts On or Off;  otherwise--it 
returns failure.

Yes, the docs specify php_flag on|off.  However many 
applications still use directives like php_flag foo 1 or 
similar--there's no reason at all to break them.

The patch below makes htscanner's php_flag act consistently 
with Apache.

Index: htscanner.c
============================================================
=======
--- htscanner.c	(revision 304374)
+++ htscanner.c	(working copy)
@@ -103,19 +103,11 @@
 
 	if (flag) {
 		/* it's a flag */
-		
-		/*
-		 * check only for valid boolean values.
-		 * Boris HUISGEN <bhuisgen@hbis.fr>
-		 */
-		if (!strcasecmp(value, "on")) {
+		if (!strcasecmp(value, "on") || (value[0] == 
'1' && value[1] == '\0')) {
 			value = "1";
-		} else if (!strcasecmp(value, "off")) {
-			value = "0";
 		} else {
-			return FAILURE;
+			value = "0";
 		}
-
 		value_len = 1;
 	} else {
 		/* it's a value */

Reproduce code:
---------------
php_flag foo !(on|off)

Expected result:
----------------
Consistent with mod_php Apache scanner.

Actual result:
--------------
Failure.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-21 08:53 UTC] martynas at venck dot us
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC