Skip to content

Commit ca75e6f

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: NEWS for #60577 NEWS for bug #64441 Fix bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names) EmptyIterator now implements Countable; fixes bug 60577 News for bugfix #64157 Bug 64157 Changed error message to make sense
2 parents ca3d5d0 + 3d6ac70 commit ca75e6f

File tree

8 files changed

+58
-8
lines changed

8 files changed

+58
-8
lines changed

ext/date/lib/parse_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25002,7 +25002,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
2500225002
TIMELIB_CHECK_NUMBER;
2500325003
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
2500425004
if (sec == TIMELIB_UNSET || length != 2) {
25005-
add_pbf_error(s, "A two second minute could not be found", string, begin);
25005+
add_pbf_error(s, "A two digit second could not be found", string, begin);
2500625006
} else {
2500725007
s->time->s = sec;
2500825008
}

ext/date/lib/parse_date.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
20092009
TIMELIB_CHECK_NUMBER;
20102010
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
20112011
if (sec == TIMELIB_UNSET || length != 2) {
2012-
add_pbf_error(s, "A two second minute could not be found", string, begin);
2012+
add_pbf_error(s, "A two digit second could not be found", string, begin);
20132013
} else {
20142014
s->time->s = sec;
20152015
}

ext/date/tests/bug64157.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test for bug #64157: DateTime::createFromFormat() reports confusing error message
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
DateTime::createFromFormat('s', '0');
10+
$lastErrors = DateTime::getLastErrors();
11+
print_r($lastErrors['errors'][0]);
12+
?>
13+
--EXPECT--
14+
A two digit second could not be found

ext/filter/logical_filters.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
484484
}
485485
s++;
486486
}
487-
488-
if (*(e - 1) == '.') {
489-
goto bad_url;
490-
}
491487
}
492488

493489
if (

ext/filter/tests/bug64441.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
bug 64441, FILTER_VALIDATE_URL will invalidate a hostname that ended by dot
3+
--SKIPIF--
4+
<?php if (!extension_loaded("filter")) die("skip"); ?>
5+
--FILE--
6+
<?php
7+
var_dump(filter_var('http://example.com./', FILTER_VALIDATE_URL));
8+
var_dump(filter_var('http://example.com/', FILTER_VALIDATE_URL));
9+
--EXPECT--
10+
string(20) "http://example.com./"
11+
string(19) "http://example.com/"

ext/spl/internal/emptyiterator.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @version 1.0
1616
* @since PHP 5.1
1717
*/
18-
class EmptyIterator implements Iterator
18+
class EmptyIterator implements Iterator, Countable
1919
{
2020
/** No operation.
2121
* @return void
@@ -57,6 +57,15 @@ class EmptyIterator implements Iterator
5757
{
5858
// nothing to do
5959
}
60+
61+
/**
62+
* @return int
63+
*/
64+
function count()
65+
{
66+
return 0;
67+
}
68+
6069
}
6170

62-
?>
71+
?>

ext/spl/spl_iterators.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,12 +3241,23 @@ SPL_METHOD(EmptyIterator, next)
32413241
}
32423242
} /* }}} */
32433243

3244+
/* {{{ proto int EmptyIterator::count()
3245+
Does nothing */
3246+
SPL_METHOD(EmptyIterator, count)
3247+
{
3248+
if (zend_parse_parameters_none() == FAILURE) {
3249+
return;
3250+
}
3251+
RETURN_LONG(0);
3252+
} /* }}} */
3253+
32443254
static const zend_function_entry spl_funcs_EmptyIterator[] = {
32453255
SPL_ME(EmptyIterator, rewind, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32463256
SPL_ME(EmptyIterator, valid, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32473257
SPL_ME(EmptyIterator, key, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32483258
SPL_ME(EmptyIterator, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32493259
SPL_ME(EmptyIterator, next, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
3260+
SPL_ME(EmptyIterator, count, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32503261
PHP_FE_END
32513262
};
32523263

@@ -3707,6 +3718,7 @@ PHP_MINIT_FUNCTION(spl_iterators)
37073718

37083719
REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator);
37093720
REGISTER_SPL_ITERATOR(EmptyIterator);
3721+
REGISTER_SPL_IMPLEMENTS(EmptyIterator, Countable);
37103722

37113723
REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator);
37123724
REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT", RTIT_BYPASS_CURRENT);

ext/spl/tests/bug60577.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
count(new EmptyIterator) should return zero
3+
--FILE--
4+
<?php
5+
$it = new EmptyIterator;
6+
var_dump(count($it));
7+
--EXPECT--
8+
int(0)

0 commit comments

Comments
 (0)