[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 016.phpt

2009-07-06 Thread Ilia Alshanetsky
iliaa   Tue Jul  7 00:44:26 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   016.phpt 
  Log:
  
  MFB: Fixed bug #48808 (FILTER_VALIDATE_EMAIL allows some invalid e-mail
  syntaxes)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.40r2=1.41diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.40 
php-src/ext/filter/logical_filters.c:1.41
--- php-src/ext/filter/logical_filters.c:1.40   Sun Jul  5 16:08:15 2009
+++ php-src/ext/filter/logical_filters.cTue Jul  7 00:44:26 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.40 2009/07/05 16:08:15 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.41 2009/07/07 00:44:26 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -476,7 +476,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
/* From 
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z\\-]*))$/D;
+   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_][A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z]+))$/D;
 
pcre   *re = NULL;
pcre_extra *pcre_extra = NULL;
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/016.phpt?r1=1.10r2=1.11diff_format=u
Index: php-src/ext/filter/tests/016.phpt
diff -u php-src/ext/filter/tests/016.phpt:1.10 
php-src/ext/filter/tests/016.phpt:1.11
--- php-src/ext/filter/tests/016.phpt:1.10  Sun Jul  5 16:08:15 2009
+++ php-src/ext/filter/tests/016.phpt   Tue Jul  7 00:44:26 2009
@@ -15,7 +15,11 @@
 '[]()/@example.com',   
 'qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net',
 'e.x.a.m.p.l...@example.com',
-'firstname.lastn...@employee.2something.com'
+'firstname.lastn...@employee.2something.com',
+'-...@foo.com',
+'f...@-.com',
+'f...@bar.123',
+'f...@bar.-'
 );
 foreach ($values as $value) {
var_dump(filter_var($value, FILTER_VALIDATE_EMAIL));
@@ -35,4 +39,8 @@
 string(57) qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net
 string(26) e.x.a.m.p.l...@example.com
 string(42) firstname.lastn...@employee.2something.com
-Done
\ No newline at end of file
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+Done



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 016.phpt

2009-07-05 Thread Ilia Alshanetsky
iliaa   Sun Jul  5 16:08:15 2009 UTC

  Modified files:  
/php-src/ext/filter/tests   016.phpt 
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB: Fixed bug #48718 (FILTER_VALIDATE_EMAIL does not allow numbers in
  domain components).
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/016.phpt?r1=1.9r2=1.10diff_format=u
Index: php-src/ext/filter/tests/016.phpt
diff -u php-src/ext/filter/tests/016.phpt:1.9 
php-src/ext/filter/tests/016.phpt:1.10
--- php-src/ext/filter/tests/016.phpt:1.9   Mon Feb  2 23:51:19 2009
+++ php-src/ext/filter/tests/016.phpt   Sun Jul  5 16:08:15 2009
@@ -14,7 +14,8 @@
 '@',   
 '[]()/@example.com',   
 'qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net',
-'e.x.a.m.p.l...@example.com'
+'e.x.a.m.p.l...@example.com',
+'firstname.lastn...@employee.2something.com'
 );
 foreach ($values as $value) {
var_dump(filter_var($value, FILTER_VALIDATE_EMAIL));
@@ -33,4 +34,5 @@
 bool(false)
 string(57) qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net
 string(26) e.x.a.m.p.l...@example.com
+string(42) firstname.lastn...@employee.2something.com
 Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.39r2=1.40diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.39 
php-src/ext/filter/logical_filters.c:1.40
--- php-src/ext/filter/logical_filters.c:1.39   Wed Jun 10 19:00:54 2009
+++ php-src/ext/filter/logical_filters.cSun Jul  5 16:08:15 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.39 2009/06/10 19:00:54 felipe Exp $ */
+/* $Id: logical_filters.c,v 1.40 2009/07/05 16:08:15 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -476,7 +476,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
/* From 
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z\\-]))?)+[A-Za-z\\-]*))$/D;
+   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z\\-]*))$/D;
 
pcre   *re = NULL;
pcre_extra *pcre_extra = NULL;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug46973.phpt

2009-06-10 Thread Felipe Pena
felipe  Wed Jun 10 19:00:54 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   bug46973.phpt 
  Log:
  - Fix the fix (Bug #46973 - IPv6 address filter rejects valid address)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.38r2=1.39diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.38 
php-src/ext/filter/logical_filters.c:1.39
--- php-src/ext/filter/logical_filters.c:1.38   Tue Mar 31 11:20:31 2009
+++ php-src/ext/filter/logical_filters.cWed Jun 10 19:00:54 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.38 2009/03/31 11:20:31 mattwil Exp $ */
+/* $Id: logical_filters.c,v 1.39 2009/06/10 19:00:54 felipe Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -574,7 +574,7 @@
}
if (*str == ':') {
if (compressed || --blocks == 0) {
-   return ipv4 != NULL;
+   return 0;
}   
if (++str == end || (ipv4  ipv4 == str)) {
return 1;
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug46973.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/bug46973.phpt
diff -u php-src/ext/filter/tests/bug46973.phpt:1.1 
php-src/ext/filter/tests/bug46973.phpt:1.2
--- php-src/ext/filter/tests/bug46973.phpt:1.1  Wed Dec 31 15:00:55 2008
+++ php-src/ext/filter/tests/bug46973.phpt  Wed Jun 10 19:00:54 2009
@@ -9,6 +9,6 @@
  
 ?
 --EXPECTF--
-string(28) 1fff::a88:85a3::172.31.128.1
+bool(false)
 string(39) 3ffe:6a88:85a3:08d3:1319:8a2e:0370:7344
-string(28) 1fff::a88:85a3::172.31.128.1
+bool(false)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug47745.phpt

2009-03-31 Thread Dmitry Stogov
dmitry  Tue Mar 31 10:02:51 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   bug47745.phpt 
  Log:
  Fixed bug #47745 (FILTER_VALIDATE_INT doesn't allow minimum integer)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.36r2=1.37diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.36 
php-src/ext/filter/logical_filters.c:1.37
--- php-src/ext/filter/logical_filters.c:1.36   Wed Mar 25 18:52:08 2009
+++ php-src/ext/filter/logical_filters.cTue Mar 31 10:02:51 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.36 2009/03/25 18:52:08 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.37 2009/03/31 10:02:51 dmitry Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -74,14 +74,12 @@
 
 static int php_filter_parse_int(const char *str, unsigned int str_len, long 
*ret TSRMLS_DC) { /* {{{ */
long ctx_value;
-   long sign = 1;
+   long sign = 0;
const char *end = str + str_len;
-   double dval;
-   long overflow;
 
switch (*str) {
case '-':
-   sign = -1;
+   sign = 1;
case '+':
str++;
default:
@@ -95,22 +93,29 @@
return -1;
}
 
+   if ((end - str  MAX_LENGTH_OF_LONG - 1) /* number too long */
+|| (SIZEOF_LONG == 4  end - str == MAX_LENGTH_OF_LONG - 1  *str  
'2')) {
+   /* overflow */
+   return -1;
+   }
+
while (str  end) {
if (*str = '0'  *str = '9') {
-   ZEND_SIGNED_MULTIPLY_LONG(ctx_value, 10, ctx_value, 
dval, overflow);
-   if (overflow) {
-   return -1;
-   }
-   ctx_value += ((*(str++)) - '0');
-   if (ctx_value  LONG_SIGN_MASK) {
-   return -1;
-   }
+   ctx_value = (ctx_value * 10) + (*(str++) - '0');
\
} else {
return -1;
}
}
+   if (sign) {
+   ctx_value = -ctx_value;
+   if (ctx_value  0) { /* overflow */
+   return -1;
+   }
+   } else if (ctx_value  0) { /* overflow */
+   return -1;
+   }
 
-   *ret = ctx_value * sign;
+   *ret = ctx_value;
return 1;
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug47745.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/bug47745.phpt
diff -u /dev/null php-src/ext/filter/tests/bug47745.phpt:1.2
--- /dev/null   Tue Mar 31 10:02:51 2009
+++ php-src/ext/filter/tests/bug47745.phpt  Tue Mar 31 10:02:51 2009
@@ -0,0 +1,11 @@
+--TEST--
+Bug #47745 (FILTER_VALIDATE_INT doesn't allow minimum integer)
+--FILE--
+?php
+$s = (string)(-PHP_INT_MAX-1);
+var_dump(intval($s));
+var_dump(filter_var($s, FILTER_VALIDATE_INT));
+?
+--EXPECTF--
+int(-%d)
+int(-%d)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2009-03-31 Thread Matt Wilmas
mattwil Tue Mar 31 11:20:31 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  - Removed unused LONG_SIGN_MASK definition, and a stray \
  - Changed sign flag to int (it's no longer being used in a calculation)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.37r2=1.38diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.37 
php-src/ext/filter/logical_filters.c:1.38
--- php-src/ext/filter/logical_filters.c:1.37   Tue Mar 31 10:02:51 2009
+++ php-src/ext/filter/logical_filters.cTue Mar 31 11:20:31 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.37 2009/03/31 10:02:51 dmitry Exp $ */
+/* $Id: logical_filters.c,v 1.38 2009/03/31 11:20:31 mattwil Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -34,8 +34,6 @@
 # include arpa/inet.h
 #endif
 
-#define LONG_SIGN_MASK (1L  (8*sizeof(long)-1))
-
 #ifndef INADDR_NONE
 # define INADDR_NONE ((unsigned long int) -1)
 #endif
@@ -74,7 +72,7 @@
 
 static int php_filter_parse_int(const char *str, unsigned int str_len, long 
*ret TSRMLS_DC) { /* {{{ */
long ctx_value;
-   long sign = 0;
+   int sign = 0;
const char *end = str + str_len;
 
switch (*str) {
@@ -101,7 +99,7 @@
 
while (str  end) {
if (*str = '0'  *str = '9') {
-   ctx_value = (ctx_value * 10) + (*(str++) - '0');
\
+   ctx_value = (ctx_value * 10) + (*(str++) - '0');
} else {
return -1;
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2009-03-25 Thread Ilia Alshanetsky
iliaa   Wed Mar 25 18:52:09 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB: Fixed bug #47772 (FILTER_VALIDATE_EMAIL allows f...@bar. addresses)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.35r2=1.36diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.35 
php-src/ext/filter/logical_filters.c:1.36
--- php-src/ext/filter/logical_filters.c:1.35   Tue Mar 10 23:39:17 2009
+++ php-src/ext/filter/logical_filters.cWed Mar 25 18:52:08 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.35 2009/03/10 23:39:17 helly Exp $ */
+/* $Id: logical_filters.c,v 1.36 2009/03/25 18:52:08 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -473,7 +473,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
/* From 
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.?)+[A-Za-z\\-]*))$/D;
+   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z\\-]))?)+[A-Za-z\\-]*))$/D;
 
pcre   *re = NULL;
pcre_extra *pcre_extra = NULL;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2009-03-08 Thread Ilia Alshanetsky
iliaa   Sun Mar  8 18:21:30 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB: Fixed bug #47598 (FILTER_VALIDATE_EMAIL is locale aware)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.33r2=1.34diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.33 
php-src/ext/filter/logical_filters.c:1.34
--- php-src/ext/filter/logical_filters.c:1.33   Mon Feb 23 16:52:45 2009
+++ php-src/ext/filter/logical_filters.cSun Mar  8 18:21:30 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.33 2009/02/23 16:52:45 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.34 2009/03/08 18:21:30 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -473,7 +473,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
/* From 
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.?)+[A-Za-z\\-]*))$/D;
+   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.?)+[A-Za-z\\-]*))$/D;
 
pcre   *re = NULL;
pcre_extra *pcre_extra = NULL;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2009-02-23 Thread Ilia Alshanetsky
iliaa   Mon Feb 23 16:52:45 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  MFB: Fixed bug #47435 (FILTER_FLAG_NO_PRIV_RANGE does not work with ipv6
  addresses in the filter extension)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.32r2=1.33diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.32 
php-src/ext/filter/logical_filters.c:1.33
--- php-src/ext/filter/logical_filters.c:1.32   Mon Feb  2 23:51:19 2009
+++ php-src/ext/filter/logical_filters.cMon Feb 23 16:52:45 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.32 2009/02/02 23:51:19 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.33 2009/02/23 16:52:45 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -659,6 +659,12 @@
if (res  1) {
RETURN_VALIDATION_FAILED
}
+   /* Check flags */
+   if (flags  FILTER_FLAG_NO_PRIV_RANGE) {
+   if (Z_STRLEN_P(value) =2  
(!strncasecmp(FC, Z_STRVAL_P(value), 2) || !strncasecmp(FD, 
Z_STRVAL_P(value), 2))) {
+   RETURN_VALIDATION_FAILED
+   }
+   }
}
break;
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 016.phpt

2009-02-02 Thread Ilia Alshanetsky
iliaa   Mon Feb  2 23:51:19 2009 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   016.phpt 
  Log:
  
  MFB: Fixed bug #47282 (FILTER_VALIDATE_EMAIL is marking valid email
  addresses as invalid)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.31r2=1.32diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.31 
php-src/ext/filter/logical_filters.c:1.32
--- php-src/ext/filter/logical_filters.c:1.31   Wed Dec 31 15:00:55 2008
+++ php-src/ext/filter/logical_filters.cMon Feb  2 23:51:19 2009
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.31 2008/12/31 15:00:55 felipe Exp $ */
+/* $Id: logical_filters.c,v 1.32 2009/02/02 23:51:19 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -473,7 +473,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
/* From 
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.)+[A-Za-z\\-]+))$/D;
+   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.?)+[A-Za-z\\-]*))$/D;
 
pcre   *re = NULL;
pcre_extra *pcre_extra = NULL;
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/016.phpt?r1=1.8r2=1.9diff_format=u
Index: php-src/ext/filter/tests/016.phpt
diff -u php-src/ext/filter/tests/016.phpt:1.8 
php-src/ext/filter/tests/016.phpt:1.9
--- php-src/ext/filter/tests/016.phpt:1.8   Tue Dec 19 14:16:07 2006
+++ php-src/ext/filter/tests/016.phpt   Mon Feb  2 23:51:19 2009
@@ -13,7 +13,8 @@
 't...@com',
 '@',   
 '[]()/@example.com',   
-'qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net',   
+'qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net',
+'e.x.a.m.p.l...@example.com'
 );
 foreach ($values as $value) {
var_dump(filter_var($value, FILTER_VALIDATE_EMAIL));
@@ -27,8 +28,9 @@
 bool(false)
 bool(false)
 bool(false)
-bool(false)
+string(8) t...@com
 bool(false)
 bool(false)
 string(57) qwertyuiopasdfghjklzxcv...@qwertyuiopasdfghjklzxcvbnm.net
-Done
+string(26) e.x.a.m.p.l...@example.com
+Done
\ No newline at end of file



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug46973.phpt

2008-12-31 Thread Felipe Pena
felipe  Wed Dec 31 15:00:55 2008 UTC

  Added files: 
/php-src/ext/filter/tests   bug46973.phpt 

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  - Fixed bug #46973 (IPv6 address filter rejects valid address)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.30r2=1.31diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.30 
php-src/ext/filter/logical_filters.c:1.31
--- php-src/ext/filter/logical_filters.c:1.30   Wed Dec 31 11:12:31 2008
+++ php-src/ext/filter/logical_filters.cWed Dec 31 15:00:55 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.30 2008/12/31 11:12:31 sebastian Exp $ */
+/* $Id: logical_filters.c,v 1.31 2008/12/31 15:00:55 felipe Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -530,7 +530,7 @@
int compressed = 0;
int blocks = 8;
int n;
-   char *ipv4;
+   char *ipv4 = NULL;
char *end;
int ip4elm[4];
char *s = str;
@@ -556,20 +556,24 @@
blocks = 6;
}
 
-   end = str + str_len;
+   end = ipv4 ? ipv4 : str + str_len;
+
while (str  end) {
if (*str == ':') {
if (--blocks == 0) {
+   if ((str+1) == end  ipv4) {
+   return 1;
+   }
return 0;
}   
if (++str = end) {
-   return 0;
+   return (ipv4  ipv4 == str  blocks == 3) || 
0;
}
if (*str == ':') {
if (compressed || --blocks == 0) {
-   return 0;
+   return ipv4 != NULL;
}   
-   if (++str == end) {
+   if (++str == end || (ipv4  ipv4 == str)) {
return 1;
}
compressed = 1;

http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug46973.phpt?view=markuprev=1.1
Index: php-src/ext/filter/tests/bug46973.phpt
+++ php-src/ext/filter/tests/bug46973.phpt
--TEST--
Bug #46973 (IPv6 address filter rejects valid address)
--FILE--
?php

var_dump(filter_var('1fff::a88:85a3::172.31.128.1', 
FILTER_VALIDATE_IP,FILTER_FLAG_IPV6));
var_dump(filter_var('3ffe:6a88:85a3:08d3:1319:8a2e:0370:7344', 
FILTER_VALIDATE_IP,FILTER_FLAG_IPV6));
var_dump(filter_var('1fff::a88:85a3::172.31.128.1', 
FILTER_VALIDATE_IP,FILTER_FLAG_IPV6));
 
?
--EXPECTF--
string(28) 1fff::a88:85a3::172.31.128.1
string(39) 3ffe:6a88:85a3:08d3:1319:8a2e:0370:7344
string(28) 1fff::a88:85a3::172.31.128.1



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2008-10-20 Thread Ilia Alshanetsky
iliaa   Mon Oct 20 23:23:53 2008 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB: Fixed bug #46343 (IPv6 address filter accepts invalid address)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.28r2=1.29diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.28 
php-src/ext/filter/logical_filters.c:1.29
--- php-src/ext/filter/logical_filters.c:1.28   Tue Mar 18 23:32:56 2008
+++ php-src/ext/filter/logical_filters.cMon Oct 20 23:23:53 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.28 2008/03/18 23:32:56 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.29 2008/10/20 23:23:53 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -533,6 +533,7 @@
char *ipv4;
char *end;
int ip4elm[4];
+   char *s = str;
 
if (!memchr(str, ':', str_len)) {
return 0;
@@ -572,6 +573,8 @@
return 1;
}
compressed = 1;
+   } else if ((str - 1) == s) {
+   return 0;
}   
}
n = 0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug44445.phpt

2008-03-18 Thread Ilia Alshanetsky
iliaa   Tue Mar 18 23:32:56 2008 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   bug5.phpt 
  Log:
  
  MFB: Bug #5 (email validator does not handle domains starting/ending
  with a -) 
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.27r2=1.28diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.27 
php-src/ext/filter/logical_filters.c:1.28
--- php-src/ext/filter/logical_filters.c:1.27   Mon Dec 31 07:12:09 2007
+++ php-src/ext/filter/logical_filters.cTue Mar 18 23:32:56 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.27 2007/12/31 07:12:09 sebastian Exp $ */
+/* $Id: logical_filters.c,v 1.28 2008/03/18 23:32:56 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -473,7 +473,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
/* From 
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\\-])+\\.)+[A-Za-z\\-]+))$/D;
+   const char regexp[] = 
/^((\\\[^\f\\n\\r\\t\\b]+\\\)|([\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.)+[A-Za-z\\-]+))$/D;
 
pcre   *re = NULL;
pcre_extra *pcre_extra = NULL;
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug5.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/bug5.phpt
diff -u /dev/null php-src/ext/filter/tests/bug5.phpt:1.2
--- /dev/null   Tue Mar 18 23:32:56 2008
+++ php-src/ext/filter/tests/bug5.phpt  Tue Mar 18 23:32:56 2008
@@ -0,0 +1,12 @@
+--TEST--
+Bug #5 (email validator does not handle domains starting/ending with a -)
+--SKIPIF--
+?php if (!extension_loaded(filter)) die(skip); ?
+--FILE--
+?php
+var_dump(filter_var([EMAIL PROTECTED],FILTER_VALIDATE_EMAIL));
+var_dump(filter_var([EMAIL PROTECTED],FILTER_VALIDATE_EMAIL));
+?
+--EXPECT-- 
+bool(false)
+bool(false)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /sapi/cgi cgi_main.c

2007-05-28 Thread Ilia Alshanetsky
iliaa   Tue May 29 00:01:14 2007 UTC

  Modified files:  
/php-src/sapi/cgi   cgi_main.c 
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.323r2=1.324diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.323 php-src/sapi/cgi/cgi_main.c:1.324
--- php-src/sapi/cgi/cgi_main.c:1.323   Mon May 28 08:12:11 2007
+++ php-src/sapi/cgi/cgi_main.c Tue May 29 00:01:14 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: cgi_main.c,v 1.323 2007/05/28 08:12:11 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.324 2007/05/29 00:01:14 iliaa Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -801,8 +801,8 @@
 * out what SCRIPT_NAME should 
be
 */
int slen = len - strlen(pt);
-   int pilen = 
strlen(env_path_info);
-   char *path_info = env_path_info 
+ pilen - slen;
+   int pilen = env_path_info ? 
strlen(env_path_info) : 0;
+   char *path_info = env_path_info 
? env_path_info + pilen - slen : NULL;
 
if (orig_path_info != 
path_info) {
if (orig_path_info) {
@@ -842,10 +842,12 @@
env_script_name = pt + 
l;
 
/* PATH_TRANSATED = 
DOCUMENT_ROOT + PATH_INFO */
-   path_translated_len = l 
+ strlen(env_path_info);
+   path_translated_len = l 
+ (env_path_info ? strlen(env_path_info) : 0);
path_translated = (char 
*) emalloc(path_translated_len + 1);
memcpy(path_translated, 
env_document_root, l);
-   memcpy(path_translated 
+ l, env_path_info, (path_translated_len - l));
+   if (env_path_info) {
+   
memcpy(path_translated + l, env_path_info, (path_translated_len - l));
+   }

path_translated[path_translated_len] = '\0';
if 
(orig_path_translated) {

_sapi_cgibin_putenv(ORIG_PATH_TRANSLATED, orig_path_translated TSRMLS_CC);
@@ -857,12 +859,14 @@
) {
/* PATH_TRANSATED = 
PATH_TRANSATED - SCRIPT_NAME + PATH_INFO */
int ptlen = strlen(pt) 
- strlen(env_script_name);
-   int path_translated_len 
= ptlen + strlen(env_path_info);
+   int path_translated_len 
= ptlen + env_path_info ? strlen(env_path_info) : 0;
char *path_translated = 
NULL;
 
path_translated = (char 
*) emalloc(path_translated_len + 1);
memcpy(path_translated, 
pt, ptlen);
-   memcpy(path_translated 
+ ptlen, env_path_info, path_translated_len - ptlen);
+   if (env_path_info) {
+   
memcpy(path_translated + ptlen, env_path_info, path_translated_len - ptlen);
+   }

path_translated[path_translated_len] = '\0';
if 
(orig_path_translated) {

_sapi_cgibin_putenv(ORIG_PATH_TRANSLATED, orig_path_translated TSRMLS_CC);
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.25r2=1.26diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.25 
php-src/ext/filter/logical_filters.c:1.26
--- php-src/ext/filter/logical_filters.c:1.25   Mon Jan  1 09:29:23 2007
+++ php-src/ext/filter/logical_filters.cTue May 29 00:01:14 2007
@@ -17,7 +17,7 @@
   

[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2006-12-31 Thread Ilia Alshanetsky
iliaa   Sun Dec 31 22:47:27 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB: Simplify code and change strchr() to memchr()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.23r2=1.24diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.23 
php-src/ext/filter/logical_filters.c:1.24
--- php-src/ext/filter/logical_filters.c:1.23   Sat Dec 30 01:56:33 2006
+++ php-src/ext/filter/logical_filters.cSun Dec 31 22:47:27 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.23 2006/12/30 01:56:33 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.24 2006/12/31 22:47:27 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -597,15 +597,12 @@
 * allow_ipv4 and allow_ipv6 flags flag are used, then the first dot or
 * colon determine the format */
 
-   char  *str = NULL;
intip[4];
intmode;
 
-   str = Z_STRVAL_P(value);
-
-   if (strchr(str, ':')) {
+   if (memchr(Z_STRVAL_P(value), ':', Z_STRLEN_P(value))) {
mode = FORMAT_IPV6;
-   } else if (strchr(str, '.')) {
+   } else if (memchr(Z_STRVAL_P(value), '.', Z_STRLEN_P(value))) {
mode = FORMAT_IPV4;
} else {
RETURN_VALIDATION_FAILED
@@ -621,7 +618,7 @@
 
switch (mode) {
case FORMAT_IPV4:
-   if (!_php_filter_validate_ipv4(str, Z_STRLEN_P(value), 
ip)) {
+   if (!_php_filter_validate_ipv4(Z_STRVAL_P(value), 
Z_STRLEN_P(value), ip)) {
RETURN_VALIDATION_FAILED
}
 
@@ -651,7 +648,7 @@
case FORMAT_IPV6:
{
int res = 0;
-   res = _php_filter_validate_ipv6(str, 
Z_STRLEN_P(value) TSRMLS_CC);
+   res = 
_php_filter_validate_ipv6(Z_STRVAL_P(value), Z_STRLEN_P(value) TSRMLS_CC);
if (res  1) {
RETURN_VALIDATION_FAILED
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2006-12-29 Thread Ilia Alshanetsky
iliaa   Sat Dec 30 01:56:33 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  
  MFB: Fixes test #50
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.22r2=1.23diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.22 
php-src/ext/filter/logical_filters.c:1.23
--- php-src/ext/filter/logical_filters.c:1.22   Tue Dec 26 09:16:39 2006
+++ php-src/ext/filter/logical_filters.cSat Dec 30 01:56:33 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.22 2006/12/26 09:16:39 dmitry Exp $ */
+/* $Id: logical_filters.c,v 1.23 2006/12/30 01:56:33 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -386,6 +386,9 @@
Z_DVAL_P(value) = lval;
break;
case IS_DOUBLE:
+   if ((!dval  p - num  1  strpbrk(num, 123456789)) 
|| !zend_finite(dval)) {
+   goto error;
+   }
zval_dtor(value);
Z_TYPE_P(value) = IS_DOUBLE;
Z_DVAL_P(value) = dval;


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 015.phpt 033.phpt

2006-12-20 Thread Ilia Alshanetsky
iliaa   Wed Dec 20 19:20:22 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   015.phpt 033.phpt 
  Log:
  MFB: Fixed bug #39898 (FILTER_VALIDATE_URL validates \r\n\t etc).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.19r2=1.20diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.19 
php-src/ext/filter/logical_filters.c:1.20
--- php-src/ext/filter/logical_filters.c:1.19   Wed Dec 20 14:37:24 2006
+++ php-src/ext/filter/logical_filters.cWed Dec 20 19:20:22 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.19 2006/12/20 14:37:24 derick Exp $ */
+/* $Id: logical_filters.c,v 1.20 2006/12/20 19:20:22 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -481,6 +481,13 @@
 void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
php_url *url;
+   int old_len = Z_STRLEN_P(value);
+   
+   php_filter_url(value, flags, option_array, charset TSRMLS_DC);
+
+   if (Z_TYPE_P(value) != IS_STRING || old_len != Z_STRLEN_P(value)) {
+   RETURN_VALIDATION_FAILED
+   }
 
/* Use parse_url - if it returns false, we return NULL */
url = php_url_parse_ex(Z_STRVAL_P(value), Z_STRLEN_P(value));
@@ -490,10 +497,10 @@
}
 
if (
-   ((flags  FILTER_FLAG_SCHEME_REQUIRED)  url-scheme == NULL) 
||
-   ((flags  FILTER_FLAG_HOST_REQUIRED)  url-host == NULL) ||
-   ((flags  FILTER_FLAG_PATH_REQUIRED)  url-path == NULL) ||
-   ((flags  FILTER_FLAG_QUERY_REQUIRED)  url-query == NULL)
+   url-scheme == NULL || 
+   /* some schemas allow the host to be empty */
+   (url-host == NULL  (strcmp(url-scheme, mailto)  
strcmp(url-scheme, news)  strcmp(url-scheme, file))) ||
+   ((flags  FILTER_FLAG_PATH_REQUIRED)  url-path == NULL) || 
((flags  FILTER_FLAG_QUERY_REQUIRED)  url-query == NULL)
) {
php_url_free(url);
RETURN_VALIDATION_FAILED
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/015.phpt?r1=1.8r2=1.9diff_format=u
Index: php-src/ext/filter/tests/015.phpt
diff -u php-src/ext/filter/tests/015.phpt:1.8 
php-src/ext/filter/tests/015.phpt:1.9
--- php-src/ext/filter/tests/015.phpt:1.8   Tue Dec 19 14:16:07 2006
+++ php-src/ext/filter/tests/015.phpt   Wed Dec 20 19:20:22 2006
@@ -24,6 +24,10 @@
 '',
 -1,
 array(),   
+'mailto:[EMAIL PROTECTED]',
+'news:news.php.net',
+'file://foo/bar',
+http://\r\n/bar;,
 );
 foreach ($values as $value) {
var_dump(filter_var($value, FILTER_VALIDATE_URL));
@@ -48,18 +52,22 @@
 string(31) http://www.example/img/test.png;
 string(27) http://www.example/img/dir/;
 string(26) http://www.example/img/dir;
-string(28) http//www.example/wrong/url/
-string(17) http:/www.example
+bool(false)
+bool(false)
 string(18) file:///tmp/test.c
 string(26) ftp://ftp.example.com/tmp/;
-string(11) /tmp/test.c
-string(1) /
 bool(false)
-string(6) http:/
-string(5) http:
-string(4) http
-string(0) 
-string(2) -1
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+string(18) mailto:[EMAIL PROTECTED]
+string(17) news:news.php.net;
+string(14) file://foo/bar
 bool(false)
 bool(false)
 string(10) http://qwe;
@@ -70,4 +78,4 @@
 string(42) http://www.example.com/path/at/the/server/;
 bool(false)
 string(40) http://www.example.com/index.php?a=bc=d;
-Done
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/033.phpt?r1=1.7r2=1.8diff_format=u
Index: php-src/ext/filter/tests/033.phpt
diff -u php-src/ext/filter/tests/033.phpt:1.7 
php-src/ext/filter/tests/033.phpt:1.8
--- php-src/ext/filter/tests/033.phpt:1.7   Tue Dec 19 14:16:08 2006
+++ php-src/ext/filter/tests/033.phpt   Wed Dec 20 19:20:22 2006
@@ -11,7 +11,7 @@
 boolean  1 

 float1   123   

 validate_regexp
   O'Henry  
-validate_urlPHP  1  [EMAIL PROTECTED]http://a.b.c1.2.3.4   
123  123abc()  O'Henry하퍼
+validate_url   http://a.b.c

 validate_email  [EMAIL PROTECTED]  
  
 validate_ip1.2.3.4 

 string  PHP  1  [EMAIL PROTECTED]

[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2006-12-17 Thread Hannes Magnusson
bjori   Sun Dec 17 12:02:19 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  MFB: fix build
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.16r2=1.17diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.16 
php-src/ext/filter/logical_filters.c:1.17
--- php-src/ext/filter/logical_filters.c:1.16   Sat Dec 16 21:48:21 2006
+++ php-src/ext/filter/logical_filters.cSun Dec 17 12:02:19 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.16 2006/12/16 21:48:21 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.17 2006/12/17 12:02:19 bjori Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -32,6 +32,11 @@
 # include arpa/inet.h
 #endif
 
+#ifndef INADDR_NONE
+# define INADDR_NONE ((unsigned long int) -1)
+#endif
+
+
 /* {{{ FETCH_LONG_OPTION(var_name, option_name) */
 #define FETCH_LONG_OPTION(var_name, option_name)   
  \
var_name = 0;   
 \
@@ -613,7 +618,7 @@
}
ipv4++;
 
-   if (!_php_filter_validate_ipv4(ipv4, (str + str_len - ipv4), 
ip4elm TSRMLS_CC)) {
+   if (!_php_filter_validate_ipv4(ipv4, (str + str_len - ipv4), 
ip4elm)) {
return 0;
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug39846.phpt

2006-12-16 Thread Ilia Alshanetsky
iliaa   Sat Dec 16 21:48:21 2006 UTC

  Modified files:  
/php-src/ext/filter/tests   bug39846.phpt 
/php-src/ext/filter logical_filters.c 
  Log:
  MFB: Fixed bug #39846 (Invalid IPv4 treated as valid).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug39846.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/bug39846.phpt
diff -u /dev/null php-src/ext/filter/tests/bug39846.phpt:1.2
--- /dev/null   Sat Dec 16 21:48:21 2006
+++ php-src/ext/filter/tests/bug39846.phpt  Sat Dec 16 21:48:21 2006
@@ -0,0 +1,10 @@
+--TEST--
+Bug #39846 ipv4 trailing data validation
+--FILE--
+?php
+var_dump(filter_var('192.168.1.100random-text-here', FILTER_VALIDATE_IP));
+var_dump(filter_var(192.168.1.155\0foo, FILTER_VALIDATE_IP));
+?
+--EXPECT-- 
+bool(false)
+bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.15r2=1.16diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.15 
php-src/ext/filter/logical_filters.c:1.16
--- php-src/ext/filter/logical_filters.c:1.15   Sun Oct 22 22:24:33 2006
+++ php-src/ext/filter/logical_filters.cSat Dec 16 21:48:21 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.15 2006/10/22 22:24:33 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.16 2006/12/16 21:48:21 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -28,6 +28,10 @@
 #define zend_ascii_hash_find(hash, name, sizeof_name, val) 
zend_hash_find(hash, name, sizeof_name, val)
 #endif
 
+#if HAVE_ARPA_INET_H
+# include arpa/inet.h
+#endif
+
 /* {{{ FETCH_LONG_OPTION(var_name, option_name) */
 #define FETCH_LONG_OPTION(var_name, option_name)   
  \
var_name = 0;   
 \
@@ -527,70 +531,31 @@
 }
 /* }}} */
 
-static int _php_filter_validate_ipv4_count_dots(char *str) /* {{{ */
-{
-   char *s1, *s2, *s3, *s4;
-
-   s1 = strchr(str, '.');
-   if (!s1)
-   return 0;
-   s2 = strchr(s1 + 1, '.');
-   if (!s2)
-   return 1;
-   s3 = strchr(s2 + 1, '.');
-   if (!s3)
-   return 2;
-   s4 = strchr(s3 + 1, '.');
-   if (!s4)
-   return 3;
-   return 4; /* too many */
-}
-/* }}} */
-
-static int _php_filter_validate_ipv4_get_nr(char **str) /* {{{ */
+static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */
 {
-   char *begin, *end, *ptr, *tmp_str;
-   int   tmp_nr = -1;
-
-   begin = ptr = *str;
-   while ((*ptr = '0')  (*ptr = '9')) {
-   ++ptr;
-   }
-   end = ptr;
-   *str = end + 1;
-
-   if (end == begin) {
-   return -1;
-   }
-
-   tmp_str = calloc(1, end - begin + 1);
-   memcpy(tmp_str, begin, end - begin);
-   tmp_nr = strtol(tmp_str, NULL, 10);
-   free(tmp_str);
-
-   if (tmp_nr  0 || tmp_nr  255) {
-   tmp_nr = -1;
+   unsigned long int i = inet_addr(str);
+   char ip_chk[16];
+   int l;
+
+   if (i == INADDR_NONE) {
+   if (!strcmp(str, 255.255.255.255)) {
+   ip[0] = ip[1] = ip[2] = ip[3] = 255;
+   return 1;
+   } else {
+   return 0;
+   }
}
-   return tmp_nr;
-}
-/* }}} */
-
-static int _php_filter_validate_ipv4(char *str, int *ip TSRMLS_DC) /* {{{ */
-{
-   char *p;
-   int x;
-
-   if (_php_filter_validate_ipv4_count_dots(str) != 3) {
+   ip[0] = i  0xFF;
+   ip[1] = (i  0xFF00) / 256;
+   ip[2] = (i  0xFF) / 256 / 256;
+   ip[3] = (i  0xFF00) / 256 / 256 / 256;
+
+   /* make sure that the input does not have any trailing values */
+   l = sprintf(ip_chk, %d.%d.%d.%d, ip[0], ip[1], ip[2], ip[3]);
+   if (l != str_len || strcmp(ip_chk, str)) {
return 0;
}
 
-   p = str;
-   for (x = 0; x  4; ++x) {
-   ip[x] = _php_filter_validate_ipv4_get_nr(p);
-   if (ip[x] == -1) {
-   return 0;
-   }
-   }
return 1;
 }
 /* }}} */
@@ -611,7 +576,7 @@
hexcode_found++;\
}
 
-static int _php_filter_validate_ipv6_(char *str TSRMLS_DC) /* {{{ */
+static int _php_filter_validate_ipv6_(char *str, int str_len TSRMLS_DC) /* {{{ 
*/
 {
int hexcode_found = 0;
int compressed_2end = 0;
@@ -621,21 +586,21 @@
char *s2 = NULL, *ipv4=NULL;
int ip4elm[4];
 
-   if (!strchr(str, ':')) {
+   if (!memchr(str, ':', str_len)) {
return 0;
}
 
/* Check for compressed expression. only one is allowed */
-   compressed = strstr(str, 

[PHP-CVS] cvs: php-src /ext/filter logical_filters.c

2006-10-22 Thread Ilia Alshanetsky
iliaa   Sun Oct 22 22:24:33 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
  Log:
  Removed unused var
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.14r2=1.15diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.14 
php-src/ext/filter/logical_filters.c:1.15
--- php-src/ext/filter/logical_filters.c:1.14   Fri Oct 20 19:11:58 2006
+++ php-src/ext/filter/logical_filters.cSun Oct 22 22:24:33 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.14 2006/10/20 19:11:58 pajoye Exp $ */
+/* $Id: logical_filters.c,v 1.15 2006/10/22 22:24:33 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -175,7 +175,7 @@
 {
zval **option_val;
long   min_range, max_range, option_flags;
-   intmin_range_set, max_range_set, option_flags_set;
+   intmin_range_set, max_range_set;
intallow_octal = 0, allow_hex = 0;
intlen, error = 0;
long   ctx_value;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 010.phpt 013.phpt 014.phpt 015.phpt 016.phpt 017.phpt 018.phpt 019.phpt 031.phpt 034.phpt bug8315.phpt filter_data.phpt

2006-10-11 Thread Derick Rethans
derick  Wed Oct 11 14:48:33 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   010.phpt 013.phpt 014.phpt 015.phpt 
016.phpt 017.phpt 018.phpt 019.phpt 
031.phpt 034.phpt bug8315.phpt 
filter_data.phpt 
  Log:
  - Change validating filters to return null on failure so that they can be
distinguised from the value false which might be valid as well.
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.11r2=1.12diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.11 
php-src/ext/filter/logical_filters.c:1.12
--- php-src/ext/filter/logical_filters.c:1.11   Wed Oct  4 11:56:15 2006
+++ php-src/ext/filter/logical_filters.cWed Oct 11 14:48:33 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.11 2006/10/04 11:56:15 pajoye Exp $ */
+/* $Id: logical_filters.c,v 1.12 2006/10/11 14:48:33 derick Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -177,7 +177,7 @@
 
if (len == 0) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
return;
}
 
@@ -217,7 +217,7 @@
 
if (error  0 || (min_range_set  (ctx_value  min_range)) || 
(max_range_set  (ctx_value  max_range))) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
} else {
zval_dtor(value);
Z_TYPE_P(value) = IS_LONG;
@@ -237,7 +237,7 @@
PHP_FILTER_TRIM_DEFAULT(str, len, end);
} else {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
return;
}
 
@@ -286,7 +286,7 @@
 
if (len  1) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
return;
}
 
@@ -425,7 +425,7 @@
 
 stateError:
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
 }
 /* }}} */
 
@@ -451,21 +451,21 @@
if (!regexp_set) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, 'regexp' option 
missing);
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
return;
}
 
re = pcre_get_compiled_regex(regexp, pcre_extra, preg_options 
TSRMLS_CC);
if (!re) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0, 
0, ovector, 3);
 
/* 0 means that the vector is too small to hold all the captured 
substring offsets */
if (matches  0) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
 }
 /* }}} */
@@ -479,25 +479,25 @@
 
if (url == NULL) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
return;
}
 
if ((flags  FILTER_FLAG_SCHEME_REQUIRED)  url-scheme == NULL) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
if ((flags  FILTER_FLAG_HOST_REQUIRED)  url-host == NULL) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
if ((flags  FILTER_FLAG_PATH_REQUIRED)  url-path == NULL) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
if ((flags  FILTER_FLAG_QUERY_REQUIRED)  url-query == NULL) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
php_url_free(url);
 }
@@ -518,14 +518,14 @@
re = pcre_get_compiled_regex((char *)regexp, pcre_extra, preg_options 
TSRMLS_CC);
if (!re) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0, 
0, ovector, 3);
 
/* 0 means that the vector is too small to hold all the captured 
substring offsets */
if (matches  0) {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
}
 
 }
@@ -767,7 +767,7 @@
mode = FORMAT_IPV4;
} else {
zval_dtor(value);
-   ZVAL_BOOL(value, 0);
+   ZVAL_NULL(value);
return;
}
 
@@ -775,11 +775,11 @@
/* Both formats are cool */
} else if ((flags  FILTER_FLAG_IPV4)  mode == 

[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug7715.phpt

2006-09-14 Thread Ilia Alshanetsky
iliaa   Thu Sep 14 17:48:11 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   bug7715.phpt 
  Log:
  MFB: Make float filter handle things like 02.324 properly
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.8r2=1.9diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.8 
php-src/ext/filter/logical_filters.c:1.9
--- php-src/ext/filter/logical_filters.c:1.8Thu Aug 31 18:28:38 2006
+++ php-src/ext/filter/logical_filters.cThu Sep 14 17:48:11 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.8 2006/08/31 18:28:38 pajoye Exp $ */
+/* $Id: logical_filters.c,v 1.9 2006/09/14 17:48:11 iliaa Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -332,9 +332,8 @@
 
ret_val = 0.0;
 
-   if (*str == '0') {
-   /* leading zeros */
-   while (*(str++) == '0');
+   while (*str == '0') {
+   str++;
}
 
if (*str == dec_sep) {
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug7715.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/bug7715.phpt
diff -u php-src/ext/filter/tests/bug7715.phpt:1.1 
php-src/ext/filter/tests/bug7715.phpt:1.2
--- php-src/ext/filter/tests/bug7715.phpt:1.1   Thu May 25 13:27:51 2006
+++ php-src/ext/filter/tests/bug7715.phpt   Thu Sep 14 17:48:11 2006
@@ -9,7 +9,8 @@
'.4',
'-.4',
'1',
-   '-1'
+   '-1',
+   '02.324'
 );
 foreach ($data as $val) {
$res = filter_data($val, FILTER_VALIDATE_FLOAT);
@@ -25,3 +26,4 @@
 float(-0.4)
 float(1.0E+12)
 float(-1.0E+12)
+float(2.324)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 010.phpt 013.phpt filter_data.phpt

2006-08-31 Thread Pierre-Alain Joye
pajoye  Thu Aug 31 18:28:39 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   010.phpt 013.phpt filter_data.phpt 
  Log:
  - pecl bug #8316,
empty strings are not int or float, return false (due to popular demand)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.7r2=1.8diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.7 
php-src/ext/filter/logical_filters.c:1.8
--- php-src/ext/filter/logical_filters.c:1.7Thu Aug 31 16:12:33 2006
+++ php-src/ext/filter/logical_filters.cThu Aug 31 18:28:38 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.7 2006/08/31 16:12:33 pajoye Exp $ */
+/* $Id: logical_filters.c,v 1.8 2006/08/31 18:28:38 pajoye Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -173,6 +173,14 @@
FETCH_LONG_OPTION(max_range,max_range);
FETCH_LONG_OPTION(option_flags, flags);
 
+   len = Z_STRLEN_P(value);
+
+   if (len == 0) {
+   zval_dtor(value);
+   ZVAL_BOOL(value, 0);
+   return;
+   }
+
if (option_flags_set  (option_flags  FILTER_FLAG_ALLOW_OCTAL)) {
allow_octal = 1;
}
@@ -181,21 +189,6 @@
allow_hex = 1;
}
 
-   len = Z_STRLEN_P(value);
-
-   if (len == 0) {
-   if ((min_range_set  (0  min_range)) || (max_range_set  (0 
 max_range))) {
-   zval_dtor(value);
-   ZVAL_BOOL(value, 0);
-   return;
-   } else {
-   zval_dtor(value);
-   Z_TYPE_P(value) = IS_LONG;
-   Z_LVAL_P(value) = 0;
-   return;
-   }
-   }
-
/* Start the validating loop */
p = Z_STRVAL_P(value);
ctx_value = 0;
@@ -245,6 +238,7 @@
} else {
zval_dtor(value);
ZVAL_BOOL(value, 0);
+   return;
}
 
/* returns true for 1, true, on and yes
@@ -292,8 +286,7 @@
 
if (len  1) {
zval_dtor(value);
-   Z_TYPE_P(value) = IS_DOUBLE;
-   Z_DVAL_P(value) = 0;
+   ZVAL_BOOL(value, 0);
return;
}
 
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/010.phpt?r1=1.4r2=1.5diff_format=u
Index: php-src/ext/filter/tests/010.phpt
diff -u php-src/ext/filter/tests/010.phpt:1.4 
php-src/ext/filter/tests/010.phpt:1.5
--- php-src/ext/filter/tests/010.phpt:1.4   Sun May 14 13:54:10 2006
+++ php-src/ext/filter/tests/010.phpt   Thu Aug 31 18:28:39 2006
@@ -21,7 +21,7 @@
   [1]=
   int(1)
   [2]=
-  int(0)
+  bool(false)
   [3]=
   int(-23234)
   [4]=
@@ -38,7 +38,7 @@
   [1]=
   float(1.7)
   [2]=
-  float(0)
+  bool(false)
   [3]=
   float(-23234.123)
   [4]=
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/013.phpt?r1=1.8r2=1.9diff_format=u
Index: php-src/ext/filter/tests/013.phpt
diff -u php-src/ext/filter/tests/013.phpt:1.8 
php-src/ext/filter/tests/013.phpt:1.9
--- php-src/ext/filter/tests/013.phpt:1.8   Thu Aug 31 16:12:33 2006
+++ php-src/ext/filter/tests/013.phpt   Thu Aug 31 18:28:39 2006
@@ -63,7 +63,7 @@
 bool(false)
 bool(false)
 int(-1)
-int(0)
+bool(false)
 bool(false)
 bool(false)
 bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/filter_data.phpt?r1=1.4r2=1.5diff_format=u
Index: php-src/ext/filter/tests/filter_data.phpt
diff -u php-src/ext/filter/tests/filter_data.phpt:1.4 
php-src/ext/filter/tests/filter_data.phpt:1.5
--- php-src/ext/filter/tests/filter_data.phpt:1.4   Sat Jan 21 15:57:43 2006
+++ php-src/ext/filter/tests/filter_data.phpt   Thu Aug 31 18:28:39 2006
@@ -46,7 +46,7 @@
 int(-123)
 int(0)
 int(123)
-int(0)
+bool(false)
 
 float(-0.123)
 float(0)
@@ -54,7 +54,7 @@
 float(-1.23)
 float(0)
 float(1.23)
-float(0)
+bool(false)
 
 bool(true)
 bool(false)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests bug8315.phpt

2006-07-29 Thread Pierre-Alain Joye
pajoye  Sat Jul 29 12:46:16 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   bug8315.phpt 
  Log:
  - MFH: #8315, float is affected too
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.5r2=1.6diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.5 
php-src/ext/filter/logical_filters.c:1.6
--- php-src/ext/filter/logical_filters.c:1.5Sat Jul 29 01:27:47 2006
+++ php-src/ext/filter/logical_filters.cSat Jul 29 12:46:16 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.5 2006/07/29 01:27:47 pajoye Exp $ */
+/* $Id: logical_filters.c,v 1.6 2006/07/29 12:46:16 pajoye Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -330,6 +330,7 @@
}
i++;
str[i] = '\0';
+   end = str + i - 1;
}
 
if (*str == '-') {
@@ -423,6 +424,9 @@
}
 
 stateT:
+   if ((str -1) != end) {
+   goto stateError;
+   }
if (exp_value) {
exp_value *= exp_multiply;
ret_val *= pow(10, exp_value);
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug8315.phpt?r1=1.2r2=1.3diff_format=u
Index: php-src/ext/filter/tests/bug8315.phpt
diff -u php-src/ext/filter/tests/bug8315.phpt:1.2 
php-src/ext/filter/tests/bug8315.phpt:1.3
--- php-src/ext/filter/tests/bug8315.phpt:1.2   Sat Jul 29 01:27:47 2006
+++ php-src/ext/filter/tests/bug8315.phpt   Sat Jul 29 12:46:16 2006
@@ -5,6 +5,9 @@
 
 $var=3.chr(0).foo;
 var_dump(filter_data($var, FILTER_VALIDATE_INT));
+$var=3.chr(0).foo;
+var_dump(filter_data($var, FILTER_VALIDATE_FLOAT));
 ?
 --EXPECTF--
 bool(false)
+bool(false)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c package.xml /ext/filter/tests bug8315.phpt

2006-07-28 Thread Pierre-Alain Joye
pajoye  Sat Jul 29 01:27:47 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c package.xml 
/php-src/ext/filter/tests   bug8315.phpt 
  Log:
  - MFH: #8315, NULL character stops the validation
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.4r2=1.5diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.4 
php-src/ext/filter/logical_filters.c:1.5
--- php-src/ext/filter/logical_filters.c:1.4Sat Jul 22 12:54:05 2006
+++ php-src/ext/filter/logical_filters.cSat Jul 29 01:27:47 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.4 2006/07/22 12:54:05 nlopess Exp $ */
+/* $Id: logical_filters.c,v 1.5 2006/07/29 01:27:47 pajoye Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -119,6 +119,7 @@
}
i++;
p[i] = '\0';
+   end = p + i - 1;
}
 
/* state 0 */
@@ -189,7 +190,7 @@
}
 
 stateT: /* state tail */
-   if (*p != '\0') {
+   if (*p != '\0' || (p-1) != end) {
goto stateE;
} else {
goto stateR;
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/package.xml?r1=1.23r2=1.24diff_format=u
Index: php-src/ext/filter/package.xml
diff -u php-src/ext/filter/package.xml:1.23 php-src/ext/filter/package.xml:1.24
--- php-src/ext/filter/package.xml:1.23 Thu Jul 20 13:08:36 2006
+++ php-src/ext/filter/package.xml  Sat Jul 29 01:27:47 2006
@@ -26,10 +26,11 @@
 statebeta/state
 version0.10.0/version
 date2006-05-14/date
-notes- Fixed PECL bug #6136, ini_set should not be able to change the 
filter.default (Pierre)
-- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported
+notes- Fixed PECL bug #8315, NULL character stops the validation (Pierre)
 - Fixed PECL bug #7733, Float exponential weird result (Pierre)
 - Fixed PECL bug #7715, Input_get float error (Pierre)
+- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported
+- Fixed PECL bug #6136, ini_set should not be able to change the 
filter.default (Pierre)
 - Implemented PECL req #6641: negative values for hexadecimal and octal 
numbers are not supported.
 - Added support for php pcre expressions (Pierre)
 - Fixed Possible leak in internal sapi_filter (Pierre)
@@ -37,7 +38,7 @@
 - Added FILTER_FLAG_SCALAR and FILTER_FLAG_ARRAY , allows or not array values 
(Pierre)
 - Basic IPv6 (no option yet, only the syntax is verified) (Pierre)
 - Add support for custom decimal separator (Pierre)
-- Integer, boolean and float filters trim the values before the validations 
(spaces only) (Pierre)
+- INT and Float filters trim the values before the validations (spaces only) 
(Pierre)
 - input_get and input_get_args returns now FALSE when the validation failed
   and NULL when the variable has not been found (Pierre)
 - Added JIT support
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug8315.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/bug8315.phpt
diff -u /dev/null php-src/ext/filter/tests/bug8315.phpt:1.2
--- /dev/null   Sat Jul 29 01:27:47 2006
+++ php-src/ext/filter/tests/bug8315.phpt   Sat Jul 29 01:27:47 2006
@@ -0,0 +1,10 @@
+--TEST--
+bug 8315, NULL values halt the validation 
+--FILE--
+?php
+
+$var=3.chr(0).foo;
+var_dump(filter_data($var, FILTER_VALIDATE_INT));
+?
+--EXPECTF--
+bool(false)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/filter logical_filters.c /ext/filter/tests 034.phpt

2006-07-20 Thread Pierre-Alain Joye
pajoye  Thu Jul 20 13:03:02 2006 UTC

  Modified files:  
/php-src/ext/filter logical_filters.c 
/php-src/ext/filter/tests   034.phpt 
  Log:
  - MFB:
   - make boolean logical filter works like int/float and php itself
   - add more tests for boolean input
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/logical_filters.c?r1=1.2r2=1.3diff_format=u
Index: php-src/ext/filter/logical_filters.c
diff -u php-src/ext/filter/logical_filters.c:1.2 
php-src/ext/filter/logical_filters.c:1.3
--- php-src/ext/filter/logical_filters.c:1.2Wed Jul 19 06:56:28 2006
+++ php-src/ext/filter/logical_filters.cThu Jul 20 13:03:02 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: logical_filters.c,v 1.2 2006/07/19 06:56:28 tony2001 Exp $ */
+/* $Id: logical_filters.c,v 1.3 2006/07/20 13:03:02 pajoye Exp $ */
 
 #include php_filter.h
 #include filter_private.h
@@ -217,20 +217,29 @@
 
 void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
+   char *str = Z_STRVAL_P(value);
+
+   if (str) {
+   /* fast(er) trim */
+   while (*str == ' ') {
+   str++;
+   }
+   }
+
/* returns true for 1, true, on and yes
 * returns false for 0, false, off, no, and 
 * null otherwise. */
-   if ((strncasecmp(Z_STRVAL_P(value), true, sizeof(true)) == 0) ||
-   (strncasecmp(Z_STRVAL_P(value), yes, sizeof(yes)) == 0) ||
-   (strncasecmp(Z_STRVAL_P(value), on, sizeof(on)) == 0) ||
-   (strncmp(Z_STRVAL_P(value), 1, sizeof(1)) == 0))
+   if ((strncasecmp(str, true, sizeof(true)) == 0) ||
+   (strncasecmp(str, yes, sizeof(yes)) == 0) ||
+   (strncasecmp(str, on, sizeof(on)) == 0) ||
+   (strncmp(str, 1, sizeof(1)) == 0))
{
zval_dtor(value);
ZVAL_BOOL(value, 1);
-   } else if ((strncasecmp(Z_STRVAL_P(value), false, sizeof(false)) == 
0) ||
-   (strncasecmp(Z_STRVAL_P(value), off, sizeof(off)) == 0) ||
-   (strncasecmp(Z_STRVAL_P(value), no, sizeof(no)) == 0) ||
-   (strncmp(Z_STRVAL_P(value), 0, sizeof(0)) == 0) ||
+   } else if ((strncasecmp(str, false, sizeof(false)) == 0) ||
+   (strncasecmp(str, off, sizeof(off)) == 0) ||
+   (strncasecmp(str, no, sizeof(no)) == 0) ||
+   (strncmp(str, 0, sizeof(0)) == 0) ||
Z_STRLEN_P(value) == 0)
{
zval_dtor(value);
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/034.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/filter/tests/034.phpt
diff -u /dev/null php-src/ext/filter/tests/034.phpt:1.2
--- /dev/null   Thu Jul 20 13:03:02 2006
+++ php-src/ext/filter/tests/034.phpt   Thu Jul 20 13:03:02 2006
@@ -0,0 +1,30 @@
+--TEST--
+Logical filter: boolean
+--FILE--
+?php
+$booleans = array(
+'1' = true,
+'On' = true,
+'Off' = true,
+'True' = true,
+'TrUe' = true,
+'oN' = true,
+
+'0' = false,
+'Off' = false,
+'False' = false,
+'faLsE' = false,
+'oFf' = false,
+'' = false
+);
+
+foreach($booleans as $val=$exp) {
+$res =filter_data($val, FILTER_VALIDATE_BOOLEAN);
+if ($res !== $exp) {
+echo $val failed,'$exp' expect, '$res' received.\n;
+}
+}
+echo Ok.;
+?
+--EXPECTF--
+Ok.

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php