Merge branch 'PHP-5.4' of https://git.php.net/repository/php-src into PHP-5.4

# By David Soria Parra (6) and others
# Via David Soria Parra
* 'PHP-5.4' of https://git.php.net/repository/php-src:
  Revert "EmptyIterator now implements Countable; fixes bug 60577"
  RFC 6598 reserved ip range starts at 100.64.0.0
  fix a very rare case of use of uninitialized value combined with a memleak
  NEWS for added reserved ip addresses according to RFC 6598
  Add RFC 6598 IPs to reserved addresses
  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
This commit is contained in:
Christopher Jones 2013-09-18 19:49:30 -07:00
commit d5ba2d8a99
8 changed files with 47 additions and 7 deletions

9
NEWS
View File

@ -6,6 +6,15 @@ PHP NEWS
. Fixed bug #65633 (built-in server treat some http headers as
case-sensitive). (Adam)
- Datetime:
. Fixed bug #64157 (DateTime::createFromFormat() reports confusing error
message). (Boro Sitnikovski)
- Filter:
. Add RFC 6598 IPs to reserved addresses. (Sebastian Nohn)
. Fixed bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names).
(Syra)
?? ??? 2013, PHP 5.4.20
- Core:

View File

@ -25036,7 +25036,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;
}

View File

@ -2043,7 +2043,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;
}

View File

@ -0,0 +1,14 @@
--TEST--
Test for bug #64157: DateTime::createFromFormat() reports confusing error message
--CREDITS--
Boro Sitnikovski <buritomath@yahoo.com>
--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

View File

@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
}
s++;
}
if (*(e - 1) == '.') {
goto bad_url;
}
}
if (
@ -718,6 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
if (flags & FILTER_FLAG_NO_RES_RANGE) {
if (
(ip[0] == 0) ||
(ip[0] == 100 && (ip[1] >= 64 || ip[1] <= 127)) ||
(ip[0] == 128 && ip[1] == 0) ||
(ip[0] == 191 && ip[1] == 255) ||
(ip[0] == 169 && ip[1] == 254) ||

View File

@ -15,6 +15,8 @@ var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
var_dump(filter_var("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var("100.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var("100.127.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP));
var_dump(filter_var("256.1237.123.1", FILTER_VALIDATE_IP));
var_dump(filter_var("255.255.255.255", FILTER_VALIDATE_IP));
@ -40,6 +42,8 @@ bool(false)
string(12) "192.0.34.166"
bool(false)
string(9) "192.0.0.1"
bool(false)
bool(false)
string(12) "192.0.34.166"
bool(false)
string(15) "255.255.255.255"

View File

@ -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/"

View File

@ -775,7 +775,12 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
* we cannot cannot getcwd() and the requested,
* relatively referenced file is accessible */
copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath);
real_path = estrndup(filepath, copy_len);
if (real_path) {
memcpy(real_path, filepath, copy_len);
real_path[copy_len] = '\0';
} else {
real_path = estrndup(filepath, copy_len);
}
close(fdtest);
return real_path;
} else {