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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martynas at venck dot us
New email:
PHP Version: OS:

 

 [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-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC