Skip to content

Commit

Permalink
Merge branch 'PHP-5.5'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dsp committed Sep 16, 2013
2 parents ca3d5d0 + 3d6ac70 commit ca75e6f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ext/date/lib/parse_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -25002,7 +25002,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
TIMELIB_CHECK_NUMBER;
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
if (sec == TIMELIB_UNSET || length != 2) {
add_pbf_error(s, "A two second minute could not be found", string, begin);
add_pbf_error(s, "A two digit second could not be found", string, begin);
} else {
s->time->s = sec;
}
Expand Down
2 changes: 1 addition & 1 deletion ext/date/lib/parse_date.re
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
TIMELIB_CHECK_NUMBER;
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
if (sec == TIMELIB_UNSET || length != 2) {
add_pbf_error(s, "A two second minute could not be found", string, begin);
add_pbf_error(s, "A two digit second could not be found", string, begin);
} else {
s->time->s = sec;
}
Expand Down
14 changes: 14 additions & 0 deletions ext/date/tests/bug64157.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Test for bug #64157: DateTime::createFromFormat() reports confusing error message
--CREDITS--
Boro Sitnikovski <[email protected]>
--INI--
date.timezone = UTC
--FILE--
<?php
DateTime::createFromFormat('s', '0');
$lastErrors = DateTime::getLastErrors();
print_r($lastErrors['errors'][0]);
?>
--EXPECT--
A two digit second could not be found
4 changes: 0 additions & 4 deletions ext/filter/logical_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
}
s++;
}

if (*(e - 1) == '.') {
goto bad_url;
}
}

if (
Expand Down
11 changes: 11 additions & 0 deletions ext/filter/tests/bug64441.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
bug 64441, FILTER_VALIDATE_URL will invalidate a hostname that ended by dot
--SKIPIF--
<?php if (!extension_loaded("filter")) die("skip"); ?>
--FILE--
<?php
var_dump(filter_var('http://example.com./', FILTER_VALIDATE_URL));
var_dump(filter_var('http://example.com/', FILTER_VALIDATE_URL));
--EXPECT--
string(20) "http://example.com./"
string(19) "http://example.com/"
13 changes: 11 additions & 2 deletions ext/spl/internal/emptyiterator.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @version 1.0
* @since PHP 5.1
*/
class EmptyIterator implements Iterator
class EmptyIterator implements Iterator, Countable
{
/** No operation.
* @return void
Expand Down Expand Up @@ -57,6 +57,15 @@ class EmptyIterator implements Iterator
{
// nothing to do
}

/**
* @return int
*/
function count()
{
return 0;
}

}

?>
?>
12 changes: 12 additions & 0 deletions ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -3241,12 +3241,23 @@ SPL_METHOD(EmptyIterator, next)
}
} /* }}} */

/* {{{ proto int EmptyIterator::count()
Does nothing */
SPL_METHOD(EmptyIterator, count)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(0);
} /* }}} */

static const zend_function_entry spl_funcs_EmptyIterator[] = {
SPL_ME(EmptyIterator, rewind, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(EmptyIterator, valid, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(EmptyIterator, key, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(EmptyIterator, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(EmptyIterator, next, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(EmptyIterator, count, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down Expand Up @@ -3707,6 +3718,7 @@ PHP_MINIT_FUNCTION(spl_iterators)

REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator);
REGISTER_SPL_ITERATOR(EmptyIterator);
REGISTER_SPL_IMPLEMENTS(EmptyIterator, Countable);

REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator);
REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT", RTIT_BYPASS_CURRENT);
Expand Down
8 changes: 8 additions & 0 deletions ext/spl/tests/bug60577.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
count(new EmptyIterator) should return zero
--FILE--
<?php
$it = new EmptyIterator;
var_dump(count($it));
--EXPECT--
int(0)

0 comments on commit ca75e6f

Please sign in to comment.