This commit is contained in:
Ilia Alshanetsky 2007-05-29 20:11:23 +00:00
parent dbfe5d3173
commit 16c9af1c7d
9 changed files with 188 additions and 7 deletions

View file

@ -449,7 +449,7 @@ PHP_FUNCTION(glob)
/* we assume that any glob pattern will match files from one directory only /* we assume that any glob pattern will match files from one directory only
so checking the dirname of the first match should be sufficient */ so checking the dirname of the first match should be sufficient */
strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); strlcpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN);
if (php_check_open_basedir(cwd TSRMLS_CC)) { if (php_check_open_basedir(cwd TSRMLS_CC)) {
RETURN_FALSE; RETURN_FALSE;

View file

@ -47,8 +47,8 @@
#define SKIP_LONG_HEADER_SEP(str, pos) \ #define SKIP_LONG_HEADER_SEP(str, pos) \
if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \ if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \
pos += 3; \ pos += 2; \
while (str[pos] == ' ' || str[pos] == '\t') { \ while (str[pos + 1] == ' ' || str[pos + 1] == '\t') { \
pos++; \ pos++; \
} \ } \
continue; \ continue; \

View file

@ -0,0 +1,28 @@
--TEST--
Bug #40709 (array_reduce() behaves strange with one item stored arrays)
--SKIPIF--
--FILE--
<?php
function CommaSeperatedList($a, $b) {
if($a == null)
return $b;
else
return $a.','.$b;
}
$arr1 = array(1,2,3);
$arr2 = array(1);
echo "result for arr1: ".array_reduce($arr1,'CommaSeperatedList')."\n";
echo "result for arr2: ".array_reduce($arr2,'CommaSeperatedList')."\n";
echo "result for arr1: ".array_reduce($arr1,'CommaSeperatedList')."\n";
echo "result for arr2: ".array_reduce($arr2,'CommaSeperatedList')."\n";
echo "Done\n";
?>
--EXPECT--
result for arr1: 1,2,3
result for arr2: 1
result for arr1: 1,2,3
result for arr2: 1
Done

View file

@ -0,0 +1,8 @@
--TEST--
Bug #40432 (strip_tags() fails with greater than in attribute)
--FILE--
<?php
echo strip_tags('<span title="test > all">this</span>') . "\n";
?>
--EXPECT--
this

View file

@ -0,0 +1,13 @@
--TEST--
Bug #40704 (strip_tags() does not handle single quotes correctly)
--FILE--
<?php
$html = "<div>Bug ' Trigger</div> Missing Text";
var_dump(strip_tags($html));
echo "Done\n";
?>
--EXPECT--
string(26) "Bug ' Trigger Missing Text"
Done

View file

@ -0,0 +1,63 @@
--TEST--
Bug #40754 (Overflow checks inside string functions)
--FILE--
<?php
$v = 2147483647;
var_dump(substr("abcde", 1, $v));
var_dump(substr_replace("abcde", "x", $v, $v));
var_dump(strspn("abcde", "abc", $v, $v));
var_dump(strcspn("abcde", "abc", $v, $v));
var_dump(substr_count("abcde", "abc", $v, $v));
var_dump(substr_compare("abcde", "abc", $v, $v));
var_dump(stripos("abcde", "abc", $v));
var_dump(substr_count("abcde", "abc", $v, 1));
var_dump(substr_count("abcde", "abc", 1, $v));
var_dump(strpos("abcde", "abc", $v));
var_dump(stripos("abcde", "abc", $v));
var_dump(strrpos("abcde", "abc", $v));
var_dump(strripos("abcde", "abc", $v));
var_dump(strncmp("abcde", "abc", $v));
var_dump(chunk_split("abcde", $v, "abc"));
var_dump(substr("abcde", $v, $v));
?>
--EXPECTF--
string(4) "bcde"
bool(false)
bool(false)
bool(false)
Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d
bool(false)
Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
bool(false)
Warning: stripos(): Offset not contained in string. in %s on line %d
bool(false)
Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d
bool(false)
Warning: substr_count(): Length value 2147483647 exceeds string length. in %s on line %d
bool(false)
Warning: strpos(): Offset not contained in string. in %s on line %d
bool(false)
Warning: stripos(): Offset not contained in string. in %s on line %d
bool(false)
Notice: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
Notice: strripos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
int(2)
string(8) "abcdeabc"
bool(false)

View file

@ -0,0 +1,40 @@
--TEST--
htmlentities() / htmlspecialchars() "don't double encode" flag support
--FILE--
<?php
$tests = array(
"abc",
"abc&amp;sfdsa",
"test&#043;s &amp; some more &#68;",
"&; &amp &#a; &9;",
"&kffjadfdhsjfhjasdhffasdfas;",
"&#8787978789",
"&",
"&&amp;&",
"&ab&amp;&",
);
foreach ($tests as $test) {
var_dump(htmlentities($test, ENT_QUOTES, NULL, FALSE));
var_dump(htmlspecialchars($test, ENT_QUOTES, NULL, FALSE));
}
?>
--EXPECT--
string(3) "abc"
string(3) "abc"
string(13) "abc&amp;sfdsa"
string(13) "abc&amp;sfdsa"
string(33) "test&#043;s &amp; some more &#68;"
string(33) "test&#043;s &amp; some more &#68;"
string(24) "&; &amp;amp &amp;#a; &9;"
string(24) "&; &amp;amp &amp;#a; &9;"
string(32) "&amp;kffjadfdhsjfhjasdhffasdfas;"
string(32) "&amp;kffjadfdhsjfhjasdhffasdfas;"
string(16) "&amp;#8787978789"
string(16) "&amp;#8787978789"
string(5) "&amp;"
string(5) "&amp;"
string(15) "&amp;&amp;&amp;"
string(15) "&amp;&amp;&amp;"
string(17) "&amp;ab&amp;&amp;"
string(17) "&amp;ab&amp;&amp;"

View file

@ -260,6 +260,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
zval *obj, *zfilter; zval *obj, *zfilter;
zval func_name; zval func_name;
zval *retval = NULL; zval *retval = NULL;
int len;
/* some sanity checks */ /* some sanity checks */
if (persistent) { if (persistent) {
@ -268,9 +269,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
return NULL; return NULL;
} }
len = strlen(filtername);
/* determine the classname/class entry */ /* determine the classname/class entry */
if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, len + 1, (void**)&fdat)) {
strlen(filtername) + 1, (void**)&fdat)) {
char *period; char *period;
/* Userspace Filters using ambiguous wildcards could cause problems. /* Userspace Filters using ambiguous wildcards could cause problems.
@ -279,10 +281,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
TODO: Allow failed userfilter creations to continue TODO: Allow failed userfilter creations to continue
scanning through the list */ scanning through the list */
if ((period = strrchr(filtername, '.'))) { if ((period = strrchr(filtername, '.'))) {
char *wildcard; char *wildcard = emalloc(len + 3);
/* Search for wildcard matches instead */ /* Search for wildcard matches instead */
wildcard = estrdup(filtername); memcpy(wildname, filtername, len + 1); /* copy \0 */
period = wildcard + (period - filtername); period = wildcard + (period - filtername);
while (period) { while (period) {
*period = '\0'; *period = '\0';

View file

@ -0,0 +1,27 @@
--TEST--
Bug #41283 (Bug with serializing array key that are doubles or floats)
--SKIPIF--
<?php if (!extension_loaded("wddx")) print "skip"; ?>
--FILE--
<?php
$data = array(
'somearray' => array('1.1' => 'One 1','1.2' => 'One 2', '1.0' => 'Three')
);
var_dump(wddx_deserialize(wddx_serialize_vars('data')));
?>
--EXPECT--
array(1) {
["data"]=>
array(1) {
["somearray"]=>
array(3) {
["1.1"]=>
string(5) "One 1"
["1.2"]=>
string(5) "One 2"
[1]=>
string(5) "Three"
}
}
}