php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #56649 Support other cases of "On", "Off", "True", and "False"
Submitted: 2005-11-14 18:46 UTC Modified: 2005-11-16 18:44 UTC
From: ramsey@php.net Assigned: derick (profile)
Status: Closed Package: filter (PECL)
PHP Version: Irrelevant OS: -
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: ramsey@php.net
New email:
PHP Version: OS:

 

 [2005-11-14 18:46 UTC] ramsey@php.net
Description:
------------
When using the FL_BOOLEAN filter, one is restricted to only "on", "off", "true", or "false". It would be nice to support multiple cases of these (i.e. On, Off, ON, OFF, TRUE, FALSE);

(I have a patch for this that I will submit.)

Reproduce code:
---------------
<?php
$boolTrue = "True";
$boolFalse = "FALSE";

var_dump(filter_data($boolTrue, FL_BOOLEAN));
var_dump(filter_data($boolFalse, FL_BOOLEAN));
?>

Expected result:
----------------
bool(true)
bool(false)

Actual result:
--------------
NULL
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-14 19:15 UTC] ramsey@php.net
Index: logical_filters.c
===================================================================
RCS file: /repository/pecl/filter/logical_filters.c,v
retrieving revision 1.8
diff -u -u -r1.8 logical_filters.c
--- logical_filters.c	28 Sep 2005 09:14:43 -0000	1.8
+++ logical_filters.c	14 Nov 2005 23:23:49 -0000
@@ -169,14 +169,14 @@
 	/* returns true for "1", "true" and "on",
 	 * returns false for "0", "false" and "off", "" and
 	 * null otherwise. */
-	if ((strcmp(Z_STRVAL_P(value), "true") == 0) ||
-		(strcmp(Z_STRVAL_P(value), "on") == 0) ||
+	if ((strcasecmp(Z_STRVAL_P(value), "true") == 0) ||
+		(strcasecmp(Z_STRVAL_P(value), "on") == 0) ||
 		(strcmp(Z_STRVAL_P(value), "1") == 0))
 	{
 		Z_TYPE_P(value) = IS_BOOL;
 		Z_LVAL_P(value) = 1;
-	} else if ((strcmp(Z_STRVAL_P(value), "false") == 0) ||
-		(strcmp(Z_STRVAL_P(value), "off") == 0) ||
+	} else if ((strcasecmp(Z_STRVAL_P(value), "false") == 0) ||
+		(strcasecmp(Z_STRVAL_P(value), "off") == 0) ||
 		(strcmp(Z_STRVAL_P(value), "0") == 0))
 	{
 		Z_TYPE_P(value) = IS_BOOL;
 [2005-11-16 18:44 UTC] sniper@php.net
This bug has been fixed in CVS.

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 17:01:58 2024 UTC