/* we assume that any glob pattern will match files from one directory only
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)) {
RETURN_FALSE;
#define SKIP_LONG_HEADER_SEP(str, pos) \
if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \
- pos += 3; \
- while (str[pos] == ' ' || str[pos] == '\t') { \
+ pos += 2; \
+ while (str[pos + 1] == ' ' || str[pos + 1] == '\t') { \
pos++; \
} \
continue; \
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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)
--- /dev/null
+--TEST--
+htmlentities() / htmlspecialchars() "don't double encode" flag support
+--FILE--
+<?php
+$tests = array(
+ "abc",
+ "abc&sfdsa",
+ "test+s & some more D",
+ "&; & &#a; &9;",
+ "&kffjadfdhsjfhjasdhffasdfas;",
+ "�",
+ "&",
+ "&&&",
+ "&ab&&",
+);
+
+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&sfdsa"
+string(13) "abc&sfdsa"
+string(33) "test+s & some more D"
+string(33) "test+s & some more D"
+string(24) "&; &amp &#a; &9;"
+string(24) "&; &amp &#a; &9;"
+string(32) "&kffjadfdhsjfhjasdhffasdfas;"
+string(32) "&kffjadfdhsjfhjasdhffasdfas;"
+string(16) "&#8787978789"
+string(16) "&#8787978789"
+string(5) "&"
+string(5) "&"
+string(15) "&&&"
+string(15) "&&&"
+string(17) "&ab&&"
+string(17) "&ab&&"
zval *obj, *zfilter;
zval func_name;
zval *retval = NULL;
+ int len;
/* some sanity checks */
if (persistent) {
return NULL;
}
+ len = strlen(filtername);
+
/* determine the classname/class entry */
- if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername,
- strlen(filtername) + 1, (void**)&fdat)) {
+ if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, len + 1, (void**)&fdat)) {
char *period;
/* Userspace Filters using ambiguous wildcards could cause problems.
TODO: Allow failed userfilter creations to continue
scanning through the list */
if ((period = strrchr(filtername, '.'))) {
- char *wildcard;
+ char *wildcard = emalloc(len + 3);
/* Search for wildcard matches instead */
- wildcard = estrdup(filtername);
+ memcpy(wildname, filtername, len + 1); /* copy \0 */
period = wildcard + (period - filtername);
while (period) {
*period = '\0';
--- /dev/null
+--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"
+ }
+ }
+}