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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sat Dec 21 15:01:29 2024 UTC