diff options
82 files changed, 618 insertions, 472 deletions
diff --git a/README.RELEASE_PROCESS b/README.RELEASE_PROCESS index 21305f2993..7a82a5c614 100644 --- a/README.RELEASE_PROCESS +++ b/README.RELEASE_PROCESS @@ -11,17 +11,27 @@ because the sysadmins can not upgrade stuff then. 2. Package two days before a release. So if the release is to be on Thursday, package on Tuesday. Think about timezones as well. -3. Ensure that Windows builds will work before packaging - -4. Follow all steps to the letter. When unclear ask previous RM's (David/Julien/ +3. Ensure that the tests on Travis CI are green. +See: https://travis-ci.org/php/php-src/builds +It is recommended to do so a couple of days before the packaging day, to +have enough time to investigate failures, communicate with the authors and +commit the fixes. +The RM for the branch is also responsible for keeping the CI green on +ongoing bases between the releases. Check the CI status for your branch +periodically and resolve the failures ASAP. See more in: +https://wiki.php.net/rfc/travis_ci + +4. Ensure that Windows builds will work before packaging + +5. Follow all steps to the letter. When unclear ask previous RM's (David/Julien/ Johannes/Stas/Derick/Ilia) before proceeding. Ideally make sure that for the first releases one of the previous RM's is around to answer questions. For the steps related to the php/QA/bug websites try to have someone from the webmaster team (Bjori) on hand. -5. Verify the tags to be extra sure everything was tagged properly. +6. Verify the tags to be extra sure everything was tagged properly. -6. Moving extensions from/to PECL requires write acces to the destination. +7. Moving extensions from/to PECL requires write acces to the destination. Most developers should have this. Moving extensions from php-src to PECL @@ -48,47 +58,49 @@ Rolling a non stable release (alpha/beta/RC) 1. Check windows snapshot builder logs (http://windows.php.net/downloads/snaps/ the last revision) -2. run the "scripts/dev/credits" script in php-src and commit the changes in the +2. Check the tests at https://travis-ci.org/php/php-src/builds + +3. run the "scripts/dev/credits" script in php-src and commit the changes in the credits files in ext/standard. -3. Checkout the release branch for this release (e.g., PHP-5.4.2) from the main branch. +4. Checkout the release branch for this release (e.g., PHP-5.4.2) from the main branch. -4. Bump the version numbers in ``main/php_version.h``, ``configure.in`` and possibly ``NEWS``. +5. Bump the version numbers in ``main/php_version.h``, ``configure.in`` and possibly ``NEWS``. Do not use abbreviations for alpha and beta. Do not use dashes, you should ``#define PHP_VERSION "5.4.22RC1"`` and not ``#define PHP_VERSION "5.4.22-RC1"`` -5. Compile and make test, with and without ZTS, using the right Bison version +6. Compile and make test, with and without ZTS, using the right Bison version (for example, for 5.5, Bison 2.4.1 is used) -6. Check ./sapi/cli/php -v output for version matching. +7. Check ./sapi/cli/php -v output for version matching. -7. If all is right, commit the changes to the release branch with ``git commit -a``. +8. If all is right, commit the changes to the release branch with ``git commit -a``. -8. Tag the repository release branch with the version, e.g.: +9. Tag the repository release branch with the version, e.g.: ``git tag -u YOURKEYID php-5.4.2RC2`` -9. Bump the version numbers in ``main/php_version.h``, ``configure.in`` and ``NEWS`` +10. Bump the version numbers in ``main/php_version.h``, ``configure.in`` and ``NEWS`` in the *main* branch (PHP-5.4 for example) to prepare for the **next** version. F.e. if the RC is "5.4.1RC1" then the new one should be "5.4.2-dev" - regardless if we get a new RC or not. This is to make sure ``version_compare()`` can correctly work. Commit the changes to the main branch. -10. Push the changes to the main repo, the tag, the main branch and the release branch : +11. Push the changes to the main repo, the tag, the main branch and the release branch : ``git push --tags origin HEAD`` ``git push origin {main branch}`` ``git push origin {release branch}`` -11. run: ``PHPROOT=. ./makedist 5.4.2RC2``, this will export the tree, create configure +12. run: ``PHPROOT=. ./makedist 5.4.2RC2``, this will export the tree, create configure and build three tarballs (gz, bz2 and xz). -12. Copy those tarballs (scp, rsync) to downloads.php.net, in your homedir there should be a +13. Copy those tarballs (scp, rsync) to downloads.php.net, in your homedir there should be a directory "downloads/". Copy them into there, so that the system can generate MD5 sums. If you do not have this directory, talk to Derick or Dan. -13. Now the RC can be found on http://downloads.php.net/yourname, +14. Now the RC can be found on http://downloads.php.net/yourname, f.e. http://downloads.php.net/derick/ -14. Once the release has been tagged, contact the PHP Windows development team +15. Once the release has been tagged, contact the PHP Windows development team (internals-win@lists.php.net) so that Windows binaries can be created. Once those are made, they should be placed into the same directory as the source snapshots. @@ -144,7 +156,8 @@ the base branches and merged upwards as usual (f.e commit the CVE fix to 5.3, merge to 5.4, 5.5 etc...). Then you can cherry-pick it in your release branch. Don't forget to update NEWS manually in an extra commit then. -3. Commit those changes +3. Commit those changes. Ensure the tests at https://travis-ci.org/php/php-src/builds are +still passing. 4. run the "scripts/dev/credits" script in php-src and commit the changes in the credits files in ext/standard. @@ -154,7 +167,7 @@ credits files in ext/standard. 6. Check ./sapi/cli/php -v output for version matching. -7. tag the repository with the version f.e. "``git tag -s php-5.4.1``" +7. tag the repository with the version f.e. "``git tag -u YOURKEYID -s php-5.4.1``" 8. Push the tag f.e. "``git push origin php-5.4.1``" diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 52689d2d6a..623d3a8031 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -115,6 +115,8 @@ again: break; } + // TODO: do we really need this warning ??? + // Nikita, add your comments here. zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to boolean", Z_OBJ_P(op)->ce->name->val); } else if (Z_OBJ_HT_P(op)->get) { zval rv; diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index 7712ee41ed..eea4de8653 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -307,9 +307,10 @@ tail_call: int i, n; zval *table; zval tmp; + HashTable *props; ZVAL_OBJ(&tmp, obj); - HashTable *props = get_gc(&tmp, &table, &n TSRMLS_CC); + props = get_gc(&tmp, &table, &n TSRMLS_CC); while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--; for (i = 0; i < n; i++) { diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index c6cebd2ed5..ded81e2918 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -278,9 +278,10 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c { zval iterator; zend_object_iterator *new_iterator; + zend_class_entry *ce_it; zend_user_it_new_iterator(ce, object, &iterator TSRMLS_CC); - zend_class_entry *ce_it = (Z_TYPE(iterator) == IS_OBJECT && + ce_it = (Z_TYPE(iterator) == IS_OBJECT && Z_OBJ_HT(iterator)->get_class_entry) ? Z_OBJCE(iterator) : NULL; if (!ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && Z_OBJ(iterator) == Z_OBJ_P(object))) { diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 4c9db85262..9e68df083d 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2522,8 +2522,8 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC) / ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) /* {{{ */ { - TSRMLS_FETCH(); zend_string *str; + TSRMLS_FETCH(); str = zend_strpprintf(0, "%.*G", (int) EG(precision), (double)Z_DVAL_P(op)); ZVAL_NEW_STR(op, str); diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 343c67061b..82a168fe07 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -551,24 +551,26 @@ static inline zend_uchar zval_get_type(const zval* pz) { #define ZVAL_NEW_RES(z, h, p, t) do { \ zend_resource *_res = emalloc(sizeof(zend_resource)); \ + zval *__z; \ GC_REFCOUNT(_res) = 1; \ GC_TYPE_INFO(_res) = IS_RESOURCE; \ _res->handle = (h); \ _res->type = (t); \ _res->ptr = (p); \ - zval *__z = (z); \ + __z = (z); \ Z_RES_P(__z) = _res; \ Z_TYPE_INFO_P(__z) = IS_RESOURCE_EX; \ } while (0) #define ZVAL_NEW_PERSISTENT_RES(z, h, p, t) do { \ zend_resource *_res = malloc(sizeof(zend_resource)); \ + zval *__z; \ GC_REFCOUNT(_res) = 1; \ GC_TYPE_INFO(_res) = IS_RESOURCE; \ _res->handle = (h); \ _res->type = (t); \ _res->ptr = (p); \ - zval *__z = (z); \ + __z = (z); \ Z_RES_P(__z) = _res; \ Z_TYPE_INFO_P(__z) = IS_RESOURCE_EX; \ } while (0) diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 8431b5214b..bd4ac68d1d 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -226,10 +226,13 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, #ifdef VIRTUAL_DIR virtual_filepath_ex(path, &path_copy, NULL TSRMLS_CC); #else - path_copy = estrdup(path); + path_copy = path; #endif if (php_check_open_basedir(path_copy TSRMLS_CC)) { +#ifdef VIRTUAL_DIR + efree(path_copy); +#endif return NULL; } @@ -237,13 +240,20 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, bz_file = BZ2_bzopen(path_copy, mode); if (opened_path && bz_file) { - *opened_path = estrdup(path_copy); +#ifdef VIRTUAL_DIR + *opened_path = path_copy; path_copy = NULL; +#else + *opened_path = estrdup(path_copy); +#endif } +#ifdef VIRTUAL_DIR if (path_copy) { efree(path_copy); } +#endif + path_copy = NULL; if (bz_file == NULL) { /* that didn't work, so try and get something from the network/wrapper */ diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 5ba7797280..15e6133fe8 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -3136,7 +3136,9 @@ PHP_FUNCTION(curl_close) return; } - zend_list_delete(Z_RES_P(zid)); + if (Z_REFCOUNT_P(zid) <= 2) { + zend_list_close(Z_RES_P(zid)); + } } /* }}} */ diff --git a/ext/curl/tests/bug27023.phpt b/ext/curl/tests/bug27023.phpt index 62effec990..fce69f5708 100644 --- a/ext/curl/tests/bug27023.phpt +++ b/ext/curl/tests/bug27023.phpt @@ -4,18 +4,15 @@ Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) error_reporting = E_ALL & ~E_DEPRECATED --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} +include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $ch = curl_init(); +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/bug27023_2.phpt b/ext/curl/tests/bug27023_2.phpt new file mode 100644 index 0000000000..c878ebac31 --- /dev/null +++ b/ext/curl/tests/bug27023_2.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) +--INI-- +error_reporting = E_ALL & ~E_DEPRECATED +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php + +include 'server.inc'; +$host = curl_cli_server_start(); +$ch = curl_init(); +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1); +curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt'); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain"); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', null, "foo.txt"); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain", "foo.txt"); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + + +curl_close($ch); +?> +--EXPECTF-- +string(%d) "curl_testdata1.txt|application/octet-stream" +string(%d) "curl_testdata1.txt|text/plain" +string(%d) "foo.txt|application/octet-stream" +string(%d) "foo.txt|text/plain" diff --git a/ext/curl/tests/bug45161.phpt b/ext/curl/tests/bug45161.phpt index 9fdc7a7e22..bfcd244004 100644 --- a/ext/curl/tests/bug45161.phpt +++ b/ext/curl/tests/bug45161.phpt @@ -8,9 +8,6 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { if (!extension_loaded("curl")) { exit("skip curl extension not loaded"); } -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} $curl_version = curl_version(); if ($curl_version['version_number'] < 0x071100) { exit("skip: test works only with curl >= 7.17.0"); diff --git a/ext/curl/tests/bug46711.phpt b/ext/curl/tests/bug46711.phpt index 8eef5562fe..3149c45d7e 100644 --- a/ext/curl/tests/bug46711.phpt +++ b/ext/curl/tests/bug46711.phpt @@ -5,9 +5,6 @@ Bug #46711 (lost memory when foreach is used for values passed to curl_setopt()) if (!extension_loaded("curl")) { exit("skip curl extension not loaded"); } -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} ?> --FILE-- <?php diff --git a/ext/curl/tests/bug48203.phpt b/ext/curl/tests/bug48203.phpt index d8f4d2269f..aae7fc51a4 100644 --- a/ext/curl/tests/bug48203.phpt +++ b/ext/curl/tests/bug48203.phpt @@ -1,24 +1,17 @@ --TEST-- Bug #48203 (Crash when CURLOPT_STDERR is set to regular file) --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - +include 'server.inc'; $fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_STDERR, $fp); -curl_setopt($ch, CURLOPT_URL, getenv('PHP_CURL_HTTP_REMOTE_SERVER')); +curl_setopt($ch, CURLOPT_URL, curl_cli_server_start()); fclose($fp); // <-- premature close of $fp caused a crash! diff --git a/ext/curl/tests/bug48203_multi.phpt b/ext/curl/tests/bug48203_multi.phpt index 501b77843e..e28c990e93 100644 --- a/ext/curl/tests/bug48203_multi.phpt +++ b/ext/curl/tests/bug48203_multi.phpt @@ -2,16 +2,11 @@ Variation of bug #48203 with curl_multi_exec (Crash when file pointers passed to curl are closed before calling curl_multi_exec) --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} +include 'skipif.inc'; ?> --FILE-- <?php - +include 'server.inc'; function checkForClosedFilePointer($curl_option, $description) { $fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w'); @@ -21,7 +16,7 @@ function checkForClosedFilePointer($curl_option, $description) { $options = array( CURLOPT_RETURNTRANSFER => 1, $curl_option => $fp, - CURLOPT_URL => getenv("PHP_CURL_HTTP_REMOTE_SERVER") + CURLOPT_URL => curl_cli_server_start() ); // we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly diff --git a/ext/curl/tests/bug48207.phpt b/ext/curl/tests/bug48207.phpt index 6ac16f5ea8..a3cd81544b 100644 --- a/ext/curl/tests/bug48207.phpt +++ b/ext/curl/tests/bug48207.phpt @@ -4,7 +4,7 @@ Test curl_setopt() CURLOPT_FILE readonly file handle Mark van der Velden #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* @@ -14,7 +14,8 @@ Mark van der Velden */ // Figure out what handler to use -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); if(!empty($host)) { // Use the set Environment variable diff --git a/ext/curl/tests/bug54798.phpt b/ext/curl/tests/bug54798.phpt index afd98cb87e..4a9b999940 100644 --- a/ext/curl/tests/bug54798.phpt +++ b/ext/curl/tests/bug54798.phpt @@ -2,12 +2,7 @@ Bug #54798 (Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec) --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} +include 'skipif.inc'; ?> --FILE-- <?php @@ -47,7 +42,8 @@ $options_to_check = array( "CURLOPT_INFILE" ); -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); foreach($options_to_check as $option) { checkForClosedFilePointer($host, constant($option), $option); } diff --git a/ext/curl/tests/bug54995.phpt b/ext/curl/tests/bug54995.phpt index 0f3f50f344..4af59948be 100644 --- a/ext/curl/tests/bug54995.phpt +++ b/ext/curl/tests/bug54995.phpt @@ -2,20 +2,16 @@ Bug #54995 (Missing CURLINFO_RESPONSE_CODE support) --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} +include 'skipif.inc'; + if ($curl_version['version_number'] > 0x070a08) { exit("skip: tests works a versions of curl >= 7.10.8"); } -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} ?> --FILE-- <?php - -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/bug55767.phpt b/ext/curl/tests/bug55767.phpt index 321f67ba60..161ced0bf1 100644 --- a/ext/curl/tests/bug55767.phpt +++ b/ext/curl/tests/bug55767.phpt @@ -2,8 +2,7 @@ Test curl_opt() function with POST params from array with a numeric key --SKIPIF-- <?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +include 'skipinf.inc'; ?> --FILE-- <?php @@ -13,7 +12,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl sending through GET an POST ***' . "\n"; diff --git a/ext/curl/tests/bug66109.phpt b/ext/curl/tests/bug66109.phpt index aacfba438a..5a18e97294 100644 --- a/ext/curl/tests/bug66109.phpt +++ b/ext/curl/tests/bug66109.phpt @@ -1,18 +1,11 @@ --TEST-- Bug #66109 (Option CURLOPT_CUSTOMREQUEST can't be reset to default.) --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=method"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/curl_CURLOPT_READDATA.phpt b/ext/curl/tests/curl_CURLOPT_READDATA.phpt index ea63d445ac..25bd0e9b49 100644 --- a/ext/curl/tests/curl_CURLOPT_READDATA.phpt +++ b/ext/curl/tests/curl_CURLOPT_READDATA.phpt @@ -4,12 +4,14 @@ Test CURLOPT_READDATA without a callback function Mattijs Hoitink mattijshoitink@gmail.com #Testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php +include 'server.inc'; +$host = curl_cli_server_start(); // The URL to POST to -$url = getenv('PHP_CURL_HTTP_REMOTE_SERVER') . '/get.php?test=post'; +$url = $host . '/get.php?test=post'; // Create a temporary file to read the data from $tempname = tempnam(sys_get_temp_dir(), 'CURL_DATA'); diff --git a/ext/curl/tests/curl_basic_001.phpt b/ext/curl/tests/curl_basic_001.phpt index fa362b33ce..4921b69bdd 100644 --- a/ext/curl/tests/curl_basic_001.phpt +++ b/ext/curl/tests/curl_basic_001.phpt @@ -4,10 +4,7 @@ Test curl_exec() function with basic functionality Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_exec(resource ch) @@ -15,8 +12,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Source code: ext/curl/interface.c * Alias to functions: */ - - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo "*** Testing curl_exec() : basic functionality ***\n"; diff --git a/ext/curl/tests/curl_basic_002.phpt b/ext/curl/tests/curl_basic_002.phpt index e46f323b5a..69aef4b825 100644 --- a/ext/curl/tests/curl_basic_002.phpt +++ b/ext/curl/tests/curl_basic_002.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with CURLOPT_RETURNTRANSFER parameter set to 1 Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_003.phpt b/ext/curl/tests/curl_basic_003.phpt index eb2aecdd8f..9c5967db8f 100644 --- a/ext/curl/tests/curl_basic_003.phpt +++ b/ext/curl/tests/curl_basic_003.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with POST parameters Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl sending through GET an POST ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_004.phpt b/ext/curl/tests/curl_basic_004.phpt index ea2eeca87c..08dc7a1005 100644 --- a/ext/curl/tests/curl_basic_004.phpt +++ b/ext/curl/tests/curl_basic_004.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with setting referer Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl setting referer ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_005.phpt b/ext/curl/tests/curl_basic_005.phpt index 9285c108e2..200db765dc 100644 --- a/ext/curl/tests/curl_basic_005.phpt +++ b/ext/curl/tests/curl_basic_005.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with user agent Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with user agent ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_006.phpt b/ext/curl/tests/curl_basic_006.phpt index 5f1a4f4839..e48a5ba70d 100644 --- a/ext/curl/tests/curl_basic_006.phpt +++ b/ext/curl/tests/curl_basic_006.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with CURLOPT_WRITEFUNCTION parameter set to a closure ? TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,23 +13,26 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl_setopt($ch, CURLOPT_WRITEFUNCTION, <closure>); ***' . "\n"; $url = "{$host}/get.php?test=get"; $ch = curl_init(); - + $alldata = ''; ob_start(); // start output buffering curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $data) { - echo 'Data: '.$data; + $GLOBALS['alldata'] .= $data; return strlen ($data); }); - + curl_exec($ch); curl_close($ch); + ob_end_flush(); + echo "Data: $alldata"; ?> ===DONE=== --EXPECTF-- diff --git a/ext/curl/tests/curl_basic_011.phpt b/ext/curl/tests/curl_basic_011.phpt index 10c90b123a..4e33082409 100644 --- a/ext/curl/tests/curl_basic_011.phpt +++ b/ext/curl/tests/curl_basic_011.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with COOKIE --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with cookie ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_012.phpt b/ext/curl/tests/curl_basic_012.phpt index e4706fad46..f136880dff 100644 --- a/ext/curl/tests/curl_basic_012.phpt +++ b/ext/curl/tests/curl_basic_012.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_0 --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with HTTP/1.0 ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_013.phpt b/ext/curl/tests/curl_basic_013.phpt index c49d187be3..6d09517e8d 100644 --- a/ext/curl/tests/curl_basic_013.phpt +++ b/ext/curl/tests/curl_basic_013.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_1 --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with HTTP/1.1 ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_017.phpt b/ext/curl/tests/curl_basic_017.phpt index 09247b2c69..dc0bee926b 100644 --- a/ext/curl/tests/curl_basic_017.phpt +++ b/ext/curl/tests/curl_basic_017.phpt @@ -3,7 +3,7 @@ Test curl_multi_exec() function with basic functionality --CREDITS-- TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_multi_exec(resource ch) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo "*** Testing curl_exec() : basic functionality ***\n"; diff --git a/ext/curl/tests/curl_basic_018.phpt b/ext/curl/tests/curl_basic_018.phpt index 7cffb89f01..359421fc0a 100644 --- a/ext/curl/tests/curl_basic_018.phpt +++ b/ext/curl/tests/curl_basic_018.phpt @@ -3,7 +3,7 @@ Test curl_setopt() with curl_multi function with basic functionality --CREDITS-- TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo "*** Testing curl_exec() : basic functionality ***\n"; diff --git a/ext/curl/tests/curl_basic_019.phpt b/ext/curl/tests/curl_basic_019.phpt index ab605a8c7d..2c58500ef7 100644 --- a/ext/curl/tests/curl_basic_019.phpt +++ b/ext/curl/tests/curl_basic_019.phpt @@ -3,22 +3,19 @@ Test curl_getinfo() function with CURLINFO_EFFECTIVE_URL parameter --CREDITS-- Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); - $url = "{$host}/get.php?test="; + $url = "http://{$host}/get.php?test="; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); $info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); var_dump($url == $info); - curl_close($ch); ?> ===DONE=== diff --git a/ext/curl/tests/curl_basic_020.phpt b/ext/curl/tests/curl_basic_020.phpt index d622053506..1227ad3261 100644 --- a/ext/curl/tests/curl_basic_020.phpt +++ b/ext/curl/tests/curl_basic_020.phpt @@ -3,13 +3,11 @@ Test curl_getinfo() function with CURLINFO_HTTP_CODE parameter --CREDITS-- Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $url = "{$host}/get.php?test="; $ch = curl_init(); diff --git a/ext/curl/tests/curl_basic_021.phpt b/ext/curl/tests/curl_basic_021.phpt index 3b4798d515..d9f5a90bef 100644 --- a/ext/curl/tests/curl_basic_021.phpt +++ b/ext/curl/tests/curl_basic_021.phpt @@ -3,13 +3,11 @@ Test curl_getinfo() function with CURLINFO_CONTENT_TYPE parameter --CREDITS-- Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $url = "{$host}/get.php?test=contenttype"; $ch = curl_init(); diff --git a/ext/curl/tests/curl_copy_handle_basic_001.phpt b/ext/curl/tests/curl_copy_handle_basic_001.phpt index f1b4db3ce5..aafa41ee2e 100644 --- a/ext/curl/tests/curl_copy_handle_basic_001.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_001.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() with simple get Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with simple GET ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_002.phpt b/ext/curl/tests/curl_copy_handle_basic_002.phpt index 9ab33635fb..6e8214ad2b 100644 --- a/ext/curl/tests/curl_copy_handle_basic_002.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_002.phpt @@ -4,10 +4,11 @@ Test curl_copy_handle() with simple POST Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with simple POST ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_004.phpt b/ext/curl/tests/curl_copy_handle_basic_004.phpt index 9b794e91b4..c690180a55 100644 --- a/ext/curl/tests/curl_copy_handle_basic_004.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_004.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() after exec() Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Test curl_copy_handle() after exec() ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_005.phpt b/ext/curl/tests/curl_copy_handle_basic_005.phpt index aa9e2fa998..e92603324e 100644 --- a/ext/curl/tests/curl_copy_handle_basic_005.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_005.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() after exec() with POST Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Test curl_copy_handle() after exec() with POST ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_006.phpt b/ext/curl/tests/curl_copy_handle_basic_006.phpt index defc0f232a..0a5c2a25e6 100644 --- a/ext/curl/tests/curl_copy_handle_basic_006.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_006.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() with User Agent Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with User Agent ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_007.phpt b/ext/curl/tests/curl_copy_handle_basic_007.phpt index aa7306c1c9..6334d2a4b8 100644 --- a/ext/curl/tests/curl_copy_handle_basic_007.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_007.phpt @@ -1,10 +1,11 @@ --TEST-- Test curl_copy_handle() with simple POST --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with simple POST using array as arguments ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_008.phpt b/ext/curl/tests/curl_copy_handle_basic_008.phpt index 692c2df192..cdb7de374d 100644 --- a/ext/curl/tests/curl_copy_handle_basic_008.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_008.phpt @@ -1,10 +1,11 @@ --TEST-- Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $url = "{$host}/get.php"; $ch = curl_init($url); diff --git a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt index 3a4d949e75..5e806add08 100644 --- a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt +++ b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt @@ -3,11 +3,13 @@ Memory corruption error if fp of just created file is closed before curl_close. --CREDITS-- Alexey Shein <confik@gmail.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$ch = curl_init(getenv('PHP_CURL_HTTP_REMOTE_SERVER')); +include 'server.inc'; +$host = curl_cli_server_start(); +$ch = curl_init($host); $temp_file = dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp'; if (file_exists($temp_file)) { diff --git a/ext/curl/tests/curl_file_upload.phpt b/ext/curl/tests/curl_file_upload.phpt index d3168e578a..3a5a78fde3 100644 --- a/ext/curl/tests/curl_file_upload.phpt +++ b/ext/curl/tests/curl_file_upload.phpt @@ -1,14 +1,8 @@ --TEST-- CURL file uploading +--INI-- --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php @@ -25,7 +19,8 @@ function testcurl($ch, $name, $mime = '', $postname = '') var_dump(curl_exec($ch)); } -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -48,6 +43,7 @@ var_dump($file->getPostFilename()); curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => $file)); var_dump(curl_exec($ch)); +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0); $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt'); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); var_dump(curl_exec($ch)); diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt index ac2a371724..190fe9d9c0 100644 --- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt +++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt @@ -4,12 +4,7 @@ Curl_multi_getcontent() basic test with different sources (local file/http) Rein Velt (rein@velt.org) #TestFest Utrecht 20090509 --SKIPIF-- -<?php -if (!extension_loaded('curl')) print 'skip need ext/curl'; -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php //CURL_MULTI_GETCONTENT TEST @@ -19,7 +14,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { $ch2=curl_init(); //SET URL AND OTHER OPTIONS - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=getpost&get_param=Hello%20World"); curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt"); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); diff --git a/ext/curl/tests/curl_setopt_array_basic.phpt b/ext/curl/tests/curl_setopt_array_basic.phpt index 427de7fc75..d858241b78 100644 --- a/ext/curl/tests/curl_setopt_array_basic.phpt +++ b/ext/curl/tests/curl_setopt_array_basic.phpt @@ -4,7 +4,7 @@ curl_setopt_array() function - tests setting multiple cURL options with curl_set Mattijs Hoitink mattijshoitink@gmail.com #Testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* @@ -15,7 +15,8 @@ Mattijs Hoitink mattijshoitink@gmail.com */ // Figure out what handler to use -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); if (!empty($host)) { // Use the set Environment variable $url = "{$host}/get.php?test=get"; diff --git a/ext/curl/tests/curl_setopt_basic002.phpt b/ext/curl/tests/curl_setopt_basic002.phpt index 074158a4b3..7a11493ed2 100644 --- a/ext/curl/tests/curl_setopt_basic002.phpt +++ b/ext/curl/tests/curl_setopt_basic002.phpt @@ -4,11 +4,12 @@ curl_setopt basic tests with CURLOPT_STDERR. Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); // start testing echo "*** Testing curl_setopt with CURLOPT_STDERR\n"; diff --git a/ext/curl/tests/curl_setopt_basic003.phpt b/ext/curl/tests/curl_setopt_basic003.phpt index aa225c6e33..246b83b418 100644 --- a/ext/curl/tests/curl_setopt_basic003.phpt +++ b/ext/curl/tests/curl_setopt_basic003.phpt @@ -4,11 +4,12 @@ curl_setopt() call with CURLOPT_HTTPHEADER Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); // start testing echo "*** curl_setopt() call with CURLOPT_HTTPHEADER\n"; diff --git a/ext/curl/tests/curl_setopt_basic004.phpt b/ext/curl/tests/curl_setopt_basic004.phpt index 97b4115e3c..ee0b4921d5 100644 --- a/ext/curl/tests/curl_setopt_basic004.phpt +++ b/ext/curl/tests/curl_setopt_basic004.phpt @@ -4,11 +4,12 @@ curl_setopt() call with CURLOPT_RETURNTRANSFER Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); // start testing echo "*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 1\n"; diff --git a/ext/curl/tests/curl_version_error.phpt b/ext/curl/tests/curl_version_error.phpt index fb4793af16..a9b80c55be 100644 --- a/ext/curl/tests/curl_version_error.phpt +++ b/ext/curl/tests/curl_version_error.phpt @@ -1,14 +1,7 @@ --TEST--
Test curl_version() function : error conditions
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- die('skip - curl extension not available in this build');
-}
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
-}
-?>
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--FILE--
<?php
diff --git a/ext/curl/tests/curl_version_variation1.phpt b/ext/curl/tests/curl_version_variation1.phpt index cd912c4803..927b4ac317 100644 --- a/ext/curl/tests/curl_version_variation1.phpt +++ b/ext/curl/tests/curl_version_variation1.phpt @@ -1,14 +1,7 @@ --TEST--
Test curl_version() function : usage variations - test values for $ascii argument
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- echo "skip - curl extension not available in this build";
-}
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
-}
-?>
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--FILE--
<?php
diff --git a/ext/curl/tests/curl_writeheader_callback.phpt b/ext/curl/tests/curl_writeheader_callback.phpt index fa27363a41..46e0cc18ba 100644 --- a/ext/curl/tests/curl_writeheader_callback.phpt +++ b/ext/curl/tests/curl_writeheader_callback.phpt @@ -4,16 +4,9 @@ Test curl option CURLOPT_HEADERFUNCTION Mathieu Kooiman <mathieuk@gmail.com> Dutch UG, TestFest 2009, Utrecht --DESCRIPTION-- -Hit the host identified by PHP_CURL_HTTP_REMOTE_SERVER and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers specified for PHP_CURL_HTTP_REMOTE_SERVER might return different sets of headers. Just test for HTTP/1.1 200 OK. +Hit the host and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers might return different sets of headers. Just test for HTTP/1.1 200 OK. --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - echo "skip - curl extension not available in this build"; -} -if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php @@ -23,7 +16,8 @@ function curl_header_callback($curl_handle, $data) echo $data; } -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/server.inc b/ext/curl/tests/server.inc new file mode 100644 index 0000000000..6d96a9850c --- /dev/null +++ b/ext/curl/tests/server.inc @@ -0,0 +1,56 @@ +<?php + +define ("PHP_CURL_SERVER_HOSTNAME", "localhost"); +define ("PHP_CURL_SERVER_PORT", 8964); +define ("PHP_CURL_SERVER_ADDRESS", PHP_CURL_SERVER_HOSTNAME.":".PHP_CURL_SERVER_PORT); + +function curl_cli_server_start() { + if(getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + return getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + } + + $php_executable = getenv('TEST_PHP_EXECUTABLE'); + $doc_root = __DIR__; + $router = "responder/get.php"; + + $descriptorspec = array( + 0 => STDIN, + 1 => STDOUT, + 2 => STDERR, + ); + + if (substr(PHP_OS, 0, 3) == 'WIN') { + $cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS; + $cmd .= " {$router}"; + $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); + } else { + $cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS; + $cmd .= " {$router}"; + $cmd .= " 2>/dev/null"; + + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); + } + + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $i = 0; + while (($i++ < 30) && !($fp = @fsockopen(PHP_CURL_SERVER_HOSTNAME, PHP_CURL_SERVER_PORT))) { + usleep(10000); + } + + if ($fp) { + fclose($fp); + } + + register_shutdown_function( + function($handle) use($router) { + proc_terminate($handle); + }, + $handle + ); + // don't bother sleeping, server is already up + // server can take a variable amount of time to be up, so just sleeping a guessed amount of time + // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass + // sleeping doesn't work. + return PHP_CURL_SERVER_ADDRESS; +} diff --git a/ext/curl/tests/skipif.inc b/ext/curl/tests/skipif.inc new file mode 100644 index 0000000000..62b252bcd1 --- /dev/null +++ b/ext/curl/tests/skipif.inc @@ -0,0 +1,7 @@ +<?php + if (!extension_loaded("curl")) exit("skip curl extension not loaded"); + if(false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + if (php_sapi_name() != "cli") { + die("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); + } + } diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 2badf294ea..46e336deb0 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -1360,7 +1360,7 @@ PHP_FUNCTION(ftp_close) ftp_quit(ftp); - RETURN_BOOL(zend_list_delete(Z_RES_P(z_ftp)) == SUCCESS); + RETURN_BOOL(zend_list_close(Z_RES_P(z_ftp)) == SUCCESS); } /* }}} */ diff --git a/ext/gd/gd.c b/ext/gd/gd.c index f4245b93fd..d7994476f0 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -4011,7 +4011,7 @@ PHP_FUNCTION(imagepsfreefont) } ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font); - zend_list_delete(Z_LVAL_P(fnt)); + zend_list_close(Z_RES_P(fnt)); RETURN_TRUE; } /* }}} */ @@ -5251,7 +5251,7 @@ PHP_FUNCTION(imageaffinematrixget) { double affine[6]; long type; - zval *options; + zval *options = NULL; zval *tmp; int res = GD_FALSE, i; @@ -5263,7 +5263,7 @@ PHP_FUNCTION(imageaffinematrixget) case GD_AFFINE_TRANSLATE: case GD_AFFINE_SCALE: { double x, y; - if (Z_TYPE_P(options) != IS_ARRAY) { + if (!options || Z_TYPE_P(options) != IS_ARRAY) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array expected as options"); RETURN_FALSE; } @@ -5308,6 +5308,10 @@ PHP_FUNCTION(imageaffinematrixget) case GD_AFFINE_SHEAR_VERTICAL: { double angle; + if (!options) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number is expected as option"); + RETURN_FALSE; + } convert_to_double_ex(options); angle = Z_DVAL_P(options); diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt new file mode 100644 index 0000000000..9c83966a60 --- /dev/null +++ b/ext/gd/tests/bug67248.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #67248 (imageaffinematrixget missing check of parameters) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available')} + if(!function_exists('imageaffinematrixget')) die('skip imageaffinematrixget() not available'); +?> +--FILE-- +<?php +for($i=0;$i<7;$i++) { + imageaffinematrixget($i); +} +?> +--EXPECTF-- +Warning: imageaffinematrixget(): Array expected as options in %s on line %d + +Warning: imageaffinematrixget(): Array expected as options in %s on line %d + +Warning: imageaffinematrixget(): Number is expected as option in %s on line %d + +Warning: imageaffinematrixget(): Number is expected as option in %s on line %d + +Warning: imageaffinematrixget(): Number is expected as option in %s on line %d + +Warning: imageaffinematrixget(): Invalid type for element 5 in %s on line %d + +Warning: imageaffinematrixget(): Invalid type for element 6 in %s on line %d diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index df7c912938..e2ece55869 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -565,6 +565,7 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch int retval = FAILURE; php_unserialize_data_t unserialize_data = (php_unserialize_data_t) data; + ZVAL_UNDEF(&zv); PHP_VAR_UNSERIALIZE_INIT(unserialize_data); gmp_create(object, &gmpnum TSRMLS_CC); @@ -579,6 +580,7 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch goto exit; } zval_dtor(&zv); + ZVAL_UNDEF(&zv); if (!php_var_unserialize(&zv, &p, max, &unserialize_data TSRMLS_CC) || Z_TYPE(zv) != IS_ARRAY diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index c0e61aa660..24c1ff9019 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -63,8 +63,8 @@ static void php_mb_regex_free_cache(zval *el) { /* {{{ _php_mb_regex_globals_ctor */ static int _php_mb_regex_globals_ctor(zend_mb_regex_globals *pglobals TSRMLS_DC) { - pglobals->default_mbctype = ONIG_ENCODING_EUC_JP; - pglobals->current_mbctype = ONIG_ENCODING_EUC_JP; + pglobals->default_mbctype = ONIG_ENCODING_UTF8; + pglobals->current_mbctype = ONIG_ENCODING_UTF8; zend_hash_init(&(pglobals->ht_rc), 0, NULL, php_mb_regex_free_cache, 1); ZVAL_UNDEF(&pglobals->search_str); pglobals->search_re = (php_mb_regex_t*)NULL; diff --git a/ext/mbstring/tests/mb_eregi_replace.phpt b/ext/mbstring/tests/mb_eregi_replace.phpt index 22ba0af13d..0405d8984c 100644 --- a/ext/mbstring/tests/mb_eregi_replace.phpt +++ b/ext/mbstring/tests/mb_eregi_replace.phpt @@ -27,8 +27,9 @@ function do_translit($st) { $st = mb_eregi_replace($i,$u,$st); } return $st; -} +} +mb_regex_encoding('ISO-8859-1'); echo do_translit("Пеар"); ?> --EXPECT-- diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 9183ed9b9f..84b0c9248c 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -588,7 +588,7 @@ PHP_FUNCTION(mcrypt_generic_init) /* If this function fails, close the mcrypt module to prevent crashes * when further functions want to access this resource */ if (result < 0) { - zend_list_delete(Z_RES_P(mcryptind)); + zend_list_close(Z_RES_P(mcryptind)); switch (result) { case -3: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Key length incorrect"); @@ -733,7 +733,7 @@ PHP_FUNCTION(mcrypt_enc_self_test) PHP_FUNCTION(mcrypt_module_close) { MCRYPT_GET_TD_ARG - zend_list_delete(Z_RES_P(mcryptind)); + zend_list_close(Z_RES_P(mcryptind)); RETURN_TRUE; } /* }}} */ diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h index e8ea47514d..f49236358e 100644 --- a/ext/mysqli/mysqli_priv.h +++ b/ext/mysqli/mysqli_priv.h @@ -114,7 +114,7 @@ PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry * TSRMLS_DC #else /* libmysql */ #define MYSQLI_ASYNC 0 -#define MYSQLI_STORE_RESULT_OFS 0 +#define MYSQLI_STORE_RESULT_COPY_DATA 0 #endif /* for mysqli_fetch_assoc */ diff --git a/ext/pcre/pcrelib/pcre_compile.c b/ext/pcre/pcrelib/pcre_compile.c index c170c47a00..853fb24793 100644 --- a/ext/pcre/pcrelib/pcre_compile.c +++ b/ext/pcre/pcrelib/pcre_compile.c @@ -3623,7 +3623,7 @@ for (;;) break; case OP_MINUPTO: - *code += OP_MINUPTO - OP_UPTO; + *code += OP_POSUPTO - OP_MINUPTO; break; } } diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 636bafae15..952dcb11bd 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1058,10 +1058,6 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, } extra->match_limit = PCRE_G(backtrack_limit); extra->match_limit_recursion = PCRE_G(recursion_limit); -#ifdef PCRE_EXTRA_MARK - extra->mark = &mark; - extra->flags |= PCRE_EXTRA_MARK; -#endif eval = pce->preg_options & PREG_REPLACE_EVAL; if (is_callable_replace) { @@ -1110,6 +1106,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, PCRE_G(error_code) = PHP_PCRE_NO_ERROR; while (1) { +#ifdef PCRE_EXTRA_MARK + extra->mark = &mark; + extra->flags |= PCRE_EXTRA_MARK; +#endif /* Execute the regular expression. */ count = pcre_exec(pce->re, extra, subject, subject_len, start_offset, exoptions|g_notempty, offsets, size_offsets); diff --git a/ext/pcre/tests/bug67238.phpt b/ext/pcre/tests/bug67238.phpt new file mode 100644 index 0000000000..117662af6b --- /dev/null +++ b/ext/pcre/tests/bug67238.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #67238 Ungreedy and min/max quantifier bug in PCRE 8.34 upstream +--FILE-- +<?php + +echo preg_match('/a{1,3}b/U', 'ab'); + +?> +--EXPECTF-- +1 diff --git a/ext/pdo_mysql/tests/common.phpt b/ext/pdo_mysql/tests/common.phpt index 18c5c1b20d..f55d1f883b 100644 --- a/ext/pdo_mysql/tests/common.phpt +++ b/ext/pdo_mysql/tests/common.phpt @@ -20,7 +20,7 @@ if (false !== getenv('PDO_MYSQL_TEST_DSN')) { $config['ENV']['PDOTEST_ATTR'] = getenv('PDO_MYSQL_TEST_ATTR'); } } else { - $config['ENV']['PDOTEST_DSN'] = 'mysql:host=127.0.0.1;port=3308;dbname=test'; + $config['ENV']['PDOTEST_DSN'] = 'mysql:host=localhost;dbname=test'; $config['ENV']['PDOTEST_USER'] = 'root'; $config['ENV']['PDOTEST_PASS'] = ''; } diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 978b036c67..d73f6ad641 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1469,7 +1469,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ } close_fp = 0; - opened = (char *) estrndup(str, sizeof("[stream]") + 1); + opened = (char *) estrndup(str, sizeof("[stream]") - 1); goto after_open_fp; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo TSRMLS_CC)) { diff --git a/ext/session/session.c b/ext/session/session.c index a21262c17d..c39e954ded 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1572,7 +1572,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ } } - /* Finally check session id for dangarous characters + /* Finally check session id for dangerous characters * Security note: session id may be embedded in HTML pages.*/ if (PS(id) && strpbrk(PS(id)->val, "\r\n\t <>'\"\\")) { STR_RELEASE(PS(id)); diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 099d9722bd..f9f7452bf4 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1249,6 +1249,9 @@ SXE_METHOD(xpath) } if (!sxe->node) { php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC); + if (!sxe->node) { + RETURN_FALSE; + } } nodeptr = php_sxe_get_first_node(sxe, sxe->node->node TSRMLS_CC); @@ -1512,15 +1515,18 @@ SXE_METHOD(getDocNamespaces) return; } - array_init(return_value); - sxe = Z_SXEOBJ_P(getThis()); if(from_root){ node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr); }else{ GET_NODE(sxe, node); } - + + if (node == NULL) { + RETURN_FALSE; + } + + array_init(return_value); sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC); } /* }}} */ diff --git a/ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt b/ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt new file mode 100644 index 0000000000..9df7591003 --- /dev/null +++ b/ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt @@ -0,0 +1,9 @@ +--TEST-- +Testing getDocNamespaces() with invalid XML +--FILE-- +<?php +$xml = @new SimpleXMLElement("X",1); +var_dump($xml->getDocNamespaces()); +?> +--EXPECTF-- +bool(false) diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt new file mode 100644 index 0000000000..4a613c2e51 --- /dev/null +++ b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt @@ -0,0 +1,8 @@ +--TEST-- +Testing xpath() with invalid XML +--FILE-- +<?php +$xml = @simplexml_load_string("XXXXXXX^",$x,0x6000000000000001); +var_dump($xml->xpath("BBBB")); +--EXPECT-- +bool(false) diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 9983025165..6936845b32 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -120,7 +120,7 @@ static void spl_fixedarray_resize(spl_fixedarray *array, long size TSRMLS_DC) /* array->elements = NULL; } } else if (size > array->size) { - array->elements = erealloc(array->elements, sizeof(zval) * size); + array->elements = safe_erealloc(array->elements, size, sizeof(zval), 0); memset(array->elements + array->size, '\0', sizeof(zval) * (size - array->size)); } else { /* size < array->size */ long i; diff --git a/ext/spl/tests/bug67247.phpt b/ext/spl/tests/bug67247.phpt new file mode 100644 index 0000000000..cb71445d7b --- /dev/null +++ b/ext/spl/tests/bug67247.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #67247 (spl_fixedarray_resize integer overflow) +--FILE-- +<?php +$ar = new SplFixedArray(1); +echo "size: ".$ar->getSize()."\n"; +$ar->setSize((PHP_INT_SIZE==8)?0x2000000000000001:0x40000001); +echo "size: ".$ar->getSize()."\n"; +?> +--EXPECTF-- +size: 1 + +Fatal error: Possible integer overflow in memory allocation (%d * %d + 0) in %s on line %d diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 3deb330a8f..7e21e95d18 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -64,7 +64,7 @@ php_stream_ops php_stream_output_ops = { }; typedef struct php_stream_input { /* {{{ */ - php_stream **body_ptr; + php_stream *body; off_t position; } php_stream_input_t; /* }}} */ @@ -85,13 +85,13 @@ static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count int read_bytes = sapi_read_post_block(buf, count TSRMLS_CC); if (read_bytes > 0) { - php_stream_seek(*input->body_ptr, 0, SEEK_END); - php_stream_write(*input->body_ptr, buf, read_bytes); + php_stream_seek(input->body, 0, SEEK_END); + php_stream_write(input->body, buf, read_bytes); } } - php_stream_seek(*input->body_ptr, input->position, SEEK_SET); - read = php_stream_read(*input->body_ptr, buf, count); + php_stream_seek(input->body, input->position, SEEK_SET); + read = php_stream_read(input->body, buf, count); if (!read || read == (size_t) -1) { stream->eof = 1; @@ -122,9 +122,9 @@ static int php_stream_input_seek(php_stream *stream, off_t offset, int whence, o { php_stream_input_t *input = stream->abstract; - if (*input->body_ptr) { - int sought = php_stream_seek(*input->body_ptr, offset, whence); - *newoffset = (*input->body_ptr)->position; + if (input->body) { + int sought = php_stream_seek(input->body, offset, whence); + *newoffset = (input->body)->position; return sought; } @@ -228,10 +228,11 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa } input = ecalloc(1, sizeof(*input)); - if (*(input->body_ptr = &SG(request_info).request_body)) { - php_stream_rewind(*input->body_ptr); + if ((input->body = SG(request_info).request_body)) { + php_stream_rewind(input->body); } else { - *input->body_ptr = php_stream_temp_create(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE); + input->body = php_stream_temp_create(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE); + SG(request_info).request_body = input->body; } return php_stream_alloc(&php_stream_input_ops, input, 0, "rb"); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 81afb2228e..1d59a97a94 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -40,6 +40,8 @@ typedef unsigned long long php_timeout_ull; typedef unsigned __int64 php_timeout_ull; #endif +#define GET_CTX_OPT(stream, wrapper, name, val) (stream->context && NULL != (val = php_stream_context_get_option(stream->context, wrapper, name))) + static php_stream_context *decode_context_param(zval *contextresource TSRMLS_DC); /* Streams based network functions */ @@ -1444,16 +1446,27 @@ PHP_FUNCTION(stream_socket_enable_crypto) long cryptokind = 0; zval *zstream, *zsessstream = NULL; php_stream *stream, *sessstream = NULL; - zend_bool enable; + zend_bool enable, cryptokindnull; int ret; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb|lr", &zstream, &enable, &cryptokind, &zsessstream) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb|l!r", &zstream, &enable, &cryptokind, &cryptokindnull, &zsessstream) == FAILURE) { RETURN_FALSE; } php_stream_from_zval(stream, zstream); - if (ZEND_NUM_ARGS() >= 3) { + if (enable) { + if (ZEND_NUM_ARGS() < 3 || cryptokindnull) { + zval *val; + + if (!GET_CTX_OPT(stream, "ssl", "crypto_method", val)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "When enabling encryption you must specify the crypto type"); + RETURN_FALSE; + } + + cryptokind = Z_LVAL_P(val); + } + if (zsessstream) { php_stream_from_zval(sessstream, zsessstream); } @@ -1461,9 +1474,6 @@ PHP_FUNCTION(stream_socket_enable_crypto) if (php_stream_xport_crypto_setup(stream, cryptokind, sessstream TSRMLS_CC) < 0) { RETURN_FALSE; } - } else if (enable) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "When enabling encryption you must specify the crypto type"); - RETURN_FALSE; } ret = php_stream_xport_crypto_enable(stream, enable TSRMLS_CC); diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index b6e27ffbb1..bb908a4113 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -212,7 +212,7 @@ PHP_FUNCTION(shm_detach) return; } SHM_FETCH_RESOURCE(shm_list_ptr, shm_id); - RETURN_BOOL(SUCCESS == zend_list_delete(Z_RES_P(shm_id))); + RETURN_BOOL(SUCCESS == zend_list_close(Z_RES_P(shm_id))); } /* }}} */ diff --git a/ext/tidy/tests/010.phpt b/ext/tidy/tests/010.phpt index 9d5ab825a0..85d9df5190 100644 --- a/ext/tidy/tests/010.phpt +++ b/ext/tidy/tests/010.phpt @@ -36,7 +36,7 @@ object(tidyNode)#2 (8) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#3 (9) { + object(tidyNode)#3 (9) { ["value"]=> string(94) "<html> <head> @@ -62,7 +62,7 @@ object(tidyNode)#2 (8) { ["child"]=> array(2) { [0]=> - &object(tidyNode)#4 (9) { + object(tidyNode)#4 (9) { ["value"]=> string(31) "<head> <title></title> @@ -85,7 +85,7 @@ object(tidyNode)#2 (8) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#5 (9) { + object(tidyNode)#5 (9) { ["value"]=> string(16) "<title></title> " @@ -109,7 +109,7 @@ object(tidyNode)#2 (8) { } } [1]=> - &object(tidyNode)#6 (9) { + object(tidyNode)#6 (9) { ["value"]=> string(49) "<body bgcolor="#FFFFFF" alink="#000000"> </body> @@ -193,7 +193,7 @@ object(tidyNode)#2 (9) { ["child"]=> array(2) { [0]=> - &object(tidyNode)#3 (9) { + object(tidyNode)#3 (9) { ["value"]=> string(31) "<head> <title></title> @@ -216,7 +216,7 @@ object(tidyNode)#2 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#6 (9) { + object(tidyNode)#6 (9) { ["value"]=> string(16) "<title></title> " @@ -240,7 +240,7 @@ object(tidyNode)#2 (9) { } } [1]=> - &object(tidyNode)#4 (9) { + object(tidyNode)#4 (9) { ["value"]=> string(49) "<body bgcolor="#FFFFFF" alink="#000000"> </body> @@ -292,7 +292,7 @@ object(tidyNode)#2 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#4 (9) { + object(tidyNode)#4 (9) { ["value"]=> string(16) "<title></title> " diff --git a/ext/tidy/tests/012.phpt b/ext/tidy/tests/012.phpt index 1205812333..39ce22bec1 100644 --- a/ext/tidy/tests/012.phpt +++ b/ext/tidy/tests/012.phpt @@ -55,7 +55,7 @@ object(tidyNode)#3 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#4 (9) { + object(tidyNode)#4 (9) { ["value"]=> string(16) "<title></title> " @@ -128,7 +128,7 @@ object(tidyNode)#5 (9) { ["child"]=> array(2) { [0]=> - &object(tidyNode)#6 (9) { + object(tidyNode)#6 (9) { ["value"]=> string(9) "<b>Hi</b>" ["name"]=> @@ -148,7 +148,7 @@ object(tidyNode)#5 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#7 (8) { + object(tidyNode)#7 (8) { ["value"]=> string(2) "Hi" ["name"]=> @@ -169,7 +169,7 @@ object(tidyNode)#5 (9) { } } [1]=> - &object(tidyNode)#8 (9) { + object(tidyNode)#8 (9) { ["value"]=> string(21) "<i>Bye<u>Test</u></i>" ["name"]=> @@ -189,7 +189,7 @@ object(tidyNode)#5 (9) { ["child"]=> array(2) { [0]=> - &object(tidyNode)#9 (8) { + object(tidyNode)#9 (8) { ["value"]=> string(3) "Bye" ["name"]=> @@ -208,7 +208,7 @@ object(tidyNode)#5 (9) { NULL } [1]=> - &object(tidyNode)#10 (9) { + object(tidyNode)#10 (9) { ["value"]=> string(11) "<u>Test</u>" ["name"]=> @@ -228,7 +228,7 @@ object(tidyNode)#5 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#11 (8) { + object(tidyNode)#11 (8) { ["value"]=> string(4) "Test" ["name"]=> @@ -273,7 +273,7 @@ object(tidyNode)#6 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#7 (8) { + object(tidyNode)#7 (8) { ["value"]=> string(2) "Hi" ["name"]=> @@ -332,7 +332,7 @@ object(tidyNode)#8 (9) { ["child"]=> array(2) { [0]=> - &object(tidyNode)#9 (8) { + object(tidyNode)#9 (8) { ["value"]=> string(3) "Bye" ["name"]=> @@ -351,7 +351,7 @@ object(tidyNode)#8 (9) { NULL } [1]=> - &object(tidyNode)#10 (9) { + object(tidyNode)#10 (9) { ["value"]=> string(11) "<u>Test</u>" ["name"]=> @@ -371,7 +371,7 @@ object(tidyNode)#8 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#11 (8) { + object(tidyNode)#11 (8) { ["value"]=> string(4) "Test" ["name"]=> @@ -432,7 +432,7 @@ object(tidyNode)#10 (9) { ["child"]=> array(1) { [0]=> - &object(tidyNode)#11 (8) { + object(tidyNode)#11 (8) { ["value"]=> string(4) "Test" ["name"]=> diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index b214467632..5617dca7d6 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -59,7 +59,7 @@ RETURN_FALSE; \ } \ } \ - obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); \ + obj = Z_TIDY_P(object); \ #define TIDY_FETCH_ONLY_OBJECT \ PHPTidyObj *obj; \ @@ -67,21 +67,21 @@ if (zend_parse_parameters_none() == FAILURE) { \ return; \ } \ - obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); \ + obj = Z_TIDY_P(object); \ #define TIDY_APPLY_CONFIG_ZVAL(_doc, _val) \ if(_val) { \ - if(Z_TYPE_PP(_val) == IS_ARRAY) { \ - _php_tidy_apply_config_array(_doc, HASH_OF(*_val) TSRMLS_CC); \ + if(Z_TYPE_P(_val) == IS_ARRAY) { \ + _php_tidy_apply_config_array(_doc, HASH_OF(_val) TSRMLS_CC); \ } else { \ convert_to_string_ex(_val); \ - TIDY_OPEN_BASE_DIR_CHECK(Z_STRVAL_PP(_val)); \ - switch (tidyLoadConfig(_doc, Z_STRVAL_PP(_val))) { \ + TIDY_OPEN_BASE_DIR_CHECK(Z_STRVAL_P(_val)); \ + switch (tidyLoadConfig(_doc, Z_STRVAL_P(_val))) { \ case -1: \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", Z_STRVAL_PP(_val)); \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", Z_STRVAL_P(_val)); \ break; \ case 1: \ - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There were errors while parsing the configuration file '%s'", Z_STRVAL_PP(_val)); \ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There were errors while parsing the configuration file '%s'", Z_STRVAL_P(_val)); \ break; \ } \ } \ @@ -111,51 +111,46 @@ #define ADD_PROPERTY_STRING(_table, _key, _string) \ { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ + zval tmp; \ if (_string) { \ - ZVAL_STRING(tmp, (char *)_string, 1); \ + ZVAL_STRING(&tmp, (char *)_string); \ } else { \ - ZVAL_EMPTY_STRING(tmp); \ + ZVAL_EMPTY_STRING(&tmp); \ } \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ + zend_hash_str_update(_table, #_key, sizeof(#_key) - 1, &tmp); \ } #define ADD_PROPERTY_STRINGL(_table, _key, _string, _len) \ { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ + zval tmp; \ if (_string) { \ - ZVAL_STRINGL(tmp, (char *)_string, _len, 1); \ + ZVAL_STRINGL(&tmp, (char *)_string, _len); \ } else { \ - ZVAL_EMPTY_STRING(tmp); \ + ZVAL_EMPTY_STRING(&tmp); \ } \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ + zend_hash_str_update(_table, #_key, sizeof(#_key) - 1, &tmp); \ } #define ADD_PROPERTY_LONG(_table, _key, _long) \ { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ - ZVAL_LONG(tmp, _long); \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ + zval tmp; \ + ZVAL_LONG(&tmp, _long); \ + zend_hash_str_update(_table, #_key, sizeof(#_key) - 1, &tmp); \ } #define ADD_PROPERTY_NULL(_table, _key) \ { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ - ZVAL_NULL(tmp); \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ + zval tmp; \ + ZVAL_NULL(&tmp); \ + zend_hash_str_update(_table, #_key, sizeof(#_key) - 1, &tmp); \ } #define ADD_PROPERTY_BOOL(_table, _key, _bool) \ { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ - ZVAL_BOOL(tmp, _bool); \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ - } + zval tmp; \ + ZVAL_BOOL(&tmp, _bool); \ + zend_hash_str_update(_table, #_key, sizeof(#_key) - 1, &tmp); \ + } #define TIDY_OPEN_BASE_DIR_CHECK(filename) \ if (php_check_open_basedir(filename TSRMLS_CC)) { \ @@ -195,19 +190,25 @@ struct _PHPTidyDoc { }; struct _PHPTidyObj { - zend_object std; TidyNode node; tidy_obj_type type; PHPTidyDoc *ptdoc; + zend_object std; }; + +static inline PHPTidyObj *php_tidy_fetch_object(zend_object *obj) { + return (PHPTidyObj *)((char*)(obj) - XtOffsetOf(PHPTidyObj, std)); +} + +#define Z_TIDY_P(zv) php_tidy_fetch_object(Z_OBJ_P((zv))) /* }}} */ /* {{{ ext/tidy prototypes */ -static char *php_tidy_file_to_mem(char *, zend_bool, int * TSRMLS_DC); -static void tidy_object_free_storage(void * TSRMLS_DC); -static zend_object_value tidy_object_new_node(zend_class_entry * TSRMLS_DC); -static zend_object_value tidy_object_new_doc(zend_class_entry * TSRMLS_DC); +static zend_string *php_tidy_file_to_mem(char *, zend_bool TSRMLS_DC); +static void tidy_object_free_storage(zend_object * TSRMLS_DC); +static zend_object *tidy_object_new_node(zend_class_entry * TSRMLS_DC); +static zend_object *tidy_object_new_doc(zend_class_entry * TSRMLS_DC); static zval * tidy_instanciate(zend_class_entry *, zval * TSRMLS_DC); static int tidy_doc_cast_handler(zval *, zval *, int TSRMLS_DC); static int tidy_node_cast_handler(zval *, zval *, int TSRMLS_DC); @@ -552,26 +553,26 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_file) { - char *data=NULL, *arg1, *enc = NULL; - int arg1_len, enc_len = 0, data_len = 0; + char *enc = NULL; + int enc_len = 0; zend_bool use_include_path = 0; TidyDoc doc; TidyBuffer *errbuf; - zval **config = NULL; + zend_string *data, *arg1; + zval *config = NULL; if (is_file) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|Zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|zsb", &arg1, &config, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } - if (!(data = php_tidy_file_to_mem(arg1, use_include_path, &data_len TSRMLS_CC))) { + if (!(data = php_tidy_file_to_mem(arg1->val, use_include_path TSRMLS_CC))) { RETURN_FALSE; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|zsb", &arg1, &config, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } data = arg1; - data_len = arg1_len; } doc = tidyCreate(); @@ -605,7 +606,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil TidyBuffer buf; tidyBufInit(&buf); - tidyBufAttach(&buf, (byte *) data, data_len); + tidyBufAttach(&buf, (byte *) data->val, data->len); if (tidyParseBuffer(doc, &buf) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf->bp); @@ -617,7 +618,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil tidySaveBuffer (doc, &output); FIX_BUFFER(&output); - RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0, 1); + RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0); tidyBufFree(&output); } else { RETVAL_FALSE; @@ -626,7 +627,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil } if (is_file) { - efree(data); + STR_RELEASE(data); } tidyBufFree(errbuf); @@ -634,26 +635,25 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil tidyRelease(doc); } -static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path, int *len TSRMLS_DC) +static zend_string *php_tidy_file_to_mem(char *filename, zend_bool use_include_path TSRMLS_DC) { php_stream *stream; - char *data = NULL; + zend_string *data = NULL; if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0), NULL))) { return NULL; } - if ((*len = (int) php_stream_copy_to_mem(stream, (void*) &data, PHP_STREAM_COPY_ALL, 0)) == 0) { - data = estrdup(""); - *len = 0; + if ((data = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) == NULL) { + data = STR_EMPTY_ALLOC(); } php_stream_close(stream); return data; } -static void tidy_object_free_storage(void *object TSRMLS_DC) +static void tidy_object_free_storage(zend_object *object TSRMLS_DC) { - PHPTidyObj *intern = (PHPTidyObj *)object; + PHPTidyObj *intern = php_tidy_fetch_object(object); zend_object_std_dtor(&intern->std TSRMLS_CC); @@ -667,17 +667,13 @@ static void tidy_object_free_storage(void *object TSRMLS_DC) efree(intern->ptdoc); } } - - efree(object); } -static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers, - zend_object_value *retval, tidy_obj_type objtype TSRMLS_DC) +static zend_object *tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers, tidy_obj_type objtype TSRMLS_DC) { PHPTidyObj *intern; - intern = emalloc(sizeof(PHPTidyObj)); - memset(intern, 0, sizeof(PHPTidyObj)); + intern = ecalloc(1, sizeof(PHPTidyObj) + sizeof(zval) * (class_type->default_properties_count - 1)); zend_object_std_init(&intern->std, class_type TSRMLS_CC); object_properties_init(&intern->std, class_type); @@ -711,34 +707,24 @@ static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers * break; } - retval->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) tidy_object_free_storage, NULL TSRMLS_CC); - retval->handlers = handlers; + intern->std.handlers = handlers; + + return &intern->std; } -static zend_object_value tidy_object_new_node(zend_class_entry *class_type TSRMLS_DC) +static zend_object *tidy_object_new_node(zend_class_entry *class_type TSRMLS_DC) { - zend_object_value retval; - tidy_object_new(class_type, &tidy_object_handlers_node, &retval, is_node TSRMLS_CC); - return retval; + return tidy_object_new(class_type, &tidy_object_handlers_node, is_node TSRMLS_CC); } -static zend_object_value tidy_object_new_doc(zend_class_entry *class_type TSRMLS_DC) +static zend_object *tidy_object_new_doc(zend_class_entry *class_type TSRMLS_DC) { - zend_object_value retval; - tidy_object_new(class_type, &tidy_object_handlers_doc, &retval, is_doc TSRMLS_CC); - return retval; + return tidy_object_new(class_type, &tidy_object_handlers_doc, is_doc TSRMLS_CC); } static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC) { - if (!object) { - ALLOC_ZVAL(object); - } - - Z_TYPE_P(object) = IS_OBJECT; object_init_ex(object, pce); - Z_SET_REFCOUNT_P(object, 1); - Z_SET_ISREF_P(object); return object; } @@ -747,7 +733,7 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type TSRMLS_DC) TidyBuffer output; PHPTidyObj *obj; - switch(type) { + switch (type) { case IS_LONG: ZVAL_LONG(out, 0); break; @@ -756,15 +742,15 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type TSRMLS_DC) ZVAL_DOUBLE(out, 0); break; - case IS_BOOL: + case _IS_BOOL: ZVAL_BOOL(out, TRUE); break; case IS_STRING: - obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC); + obj = Z_TIDY_P(in); tidyBufInit(&output); tidySaveBuffer (obj->ptdoc->doc, &output); - ZVAL_STRINGL(out, (char *) output.bp, output.size ? output.size-1 : 0, 1); + ZVAL_STRINGL(out, (char *) output.bp, output.size ? output.size-1 : 0); tidyBufFree(&output); break; @@ -789,16 +775,16 @@ static int tidy_node_cast_handler(zval *in, zval *out, int type TSRMLS_DC) ZVAL_DOUBLE(out, 0); break; - case IS_BOOL: + case _IS_BOOL: ZVAL_BOOL(out, TRUE); break; case IS_STRING: - obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC); + obj = Z_TIDY_P(in); tidyBufInit(&buf); if (obj->ptdoc) { tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf); - ZVAL_STRINGL(out, (char *) buf.bp, buf.size-1, 1); + ZVAL_STRINGL(out, (char *) buf.bp, buf.size-1); } else { ZVAL_EMPTY_STRING(out); } @@ -816,7 +802,7 @@ static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC) { TidyBuffer output; - zval *temp; + zval temp; tidyBufInit(&output); tidySaveBuffer (obj->ptdoc->doc, &output); @@ -825,9 +811,8 @@ static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC) if (!obj->std.properties) { rebuild_object_properties(&obj->std); } - MAKE_STD_ZVAL(temp); - ZVAL_STRINGL(temp, (char*)output.bp, output.size-1, TRUE); - zend_hash_update(obj->std.properties, "value", sizeof("value"), (void *)&temp, sizeof(zval *), NULL); + ZVAL_STRINGL(&temp, (char*)output.bp, output.size-1); + zend_hash_str_update(obj->std.properties, "value", sizeof("value") - 1, &temp); } tidyBufFree(&output); @@ -836,9 +821,8 @@ static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC) if (!obj->std.properties) { rebuild_object_properties(&obj->std); } - MAKE_STD_ZVAL(temp); - ZVAL_STRINGL(temp, (char*)obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, TRUE); - zend_hash_update(obj->std.properties, "errorBuffer", sizeof("errorBuffer"), (void *)&temp, sizeof(zval *), NULL); + ZVAL_STRINGL(&temp, (char*)obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1); + zend_hash_str_update(obj->std.properties, "errorBuffer", sizeof("errorBuffer") - 1, &temp); } } @@ -848,7 +832,7 @@ static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRM TidyBuffer buf; TidyAttr tempattr; TidyNode tempnode; - zval *attribute, *children, *temp; + zval attribute, children, temp; PHPTidyObj *newobj; switch(type) { @@ -880,48 +864,45 @@ static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRM } tempattr = tidyAttrFirst(obj->node); - MAKE_STD_ZVAL(attribute); if (tempattr) { char *name, *val; - array_init(attribute); + array_init(&attribute); do { name = (char *)tidyAttrName(tempattr); val = (char *)tidyAttrValue(tempattr); if (name && val) { - add_assoc_string(attribute, name, val); + add_assoc_string(&attribute, name, val); } } while((tempattr = tidyAttrNext(tempattr))); } else { - ZVAL_NULL(attribute); + ZVAL_NULL(&attribute); } - zend_hash_update(obj->std.properties, "attribute", sizeof("attribute"), (void *)&attribute, sizeof(zval *), NULL); + zend_hash_str_update(obj->std.properties, "attribute", sizeof("attribute") - 1, &attribute); tempnode = tidyGetChild(obj->node); - MAKE_STD_ZVAL(children); if (tempnode) { - array_init(children); + array_init(&children); do { - MAKE_STD_ZVAL(temp); - tidy_instanciate(tidy_ce_node, temp TSRMLS_CC); - newobj = (PHPTidyObj *) zend_object_store_get_object(temp TSRMLS_CC); + tidy_instanciate(tidy_ce_node, &temp TSRMLS_CC); + newobj = Z_TIDY_P(&temp); newobj->node = tempnode; newobj->type = is_node; newobj->ptdoc = obj->ptdoc; newobj->ptdoc->ref_count++; tidy_add_default_properties(newobj, is_node TSRMLS_CC); - add_next_index_zval(children, temp); + add_next_index_zval(&children, &temp); } while((tempnode = tidyGetNext(tempnode))); } else { - ZVAL_NULL(children); + ZVAL_NULL(&children); } - zend_hash_update(obj->std.properties, "child", sizeof("child"), (void *)&children, sizeof(zval *), NULL); + zend_hash_str_update(obj->std.properties, "child", sizeof("child") - 1, &children); break; @@ -996,7 +977,7 @@ static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetyp } tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - newobj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); + newobj = Z_TIDY_P(return_value); newobj->type = is_node; newobj->ptdoc = obj->ptdoc; newobj->node = node; @@ -1007,34 +988,16 @@ static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetyp static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRMLS_DC) { - char *opt_name; - zval **opt_val; + zval *opt_val; ulong opt_indx; - uint opt_name_len; - zend_bool clear_str; - - for (zend_hash_internal_pointer_reset(ht_options); - zend_hash_get_current_data(ht_options, (void *) &opt_val) == SUCCESS; - zend_hash_move_forward(ht_options)) { - - switch (zend_hash_get_current_key_ex(ht_options, &opt_name, &opt_name_len, &opt_indx, FALSE, NULL)) { - case HASH_KEY_IS_STRING: - clear_str = 0; - break; - - case HASH_KEY_IS_LONG: - continue; /* ignore numeric keys */ - - default: - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not retrieve key from option array"); - return FAILURE; - } + zend_string *opt_name; - _php_tidy_set_tidy_opt(doc, opt_name, *opt_val TSRMLS_CC); - if (clear_str) { - efree(opt_name); + ZEND_HASH_FOREACH_KEY_VAL(ht_options, opt_indx, opt_name, opt_val) { + if (opt_name == NULL) { + continue; } - } + _php_tidy_set_tidy_opt(doc, opt_name->val, opt_val TSRMLS_CC); + } ZEND_HASH_FOREACH_END(); return SUCCESS; } @@ -1077,6 +1040,9 @@ static PHP_MINIT_FUNCTION(tidy) tidy_object_handlers_doc.cast_object = tidy_doc_cast_handler; tidy_object_handlers_node.cast_object = tidy_node_cast_handler; + tidy_object_handlers_node.offset = tidy_object_handlers_doc.offset = XtOffsetOf(PHPTidyObj, std); + tidy_object_handlers_node.free_obj = tidy_object_handlers_doc.free_obj = tidy_object_free_storage; + _php_tidy_register_tags(INIT_FUNC_ARGS_PASSTHRU); _php_tidy_register_nodetypes(INIT_FUNC_ARGS_PASSTHRU); @@ -1215,23 +1181,23 @@ static int php_tidy_output_handler(void **nothing, php_output_context *output_co Parse a document stored in a string */ static PHP_FUNCTION(tidy_parse_string) { - char *input, *enc = NULL; - int input_len, enc_len = 0; - zval **options = NULL; + char *enc = NULL; + int enc_len = 0; + zend_string *input; + zval *options = NULL; PHPTidyObj *obj; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|zs", &input, &options, &enc, &enc_len) == FAILURE) { RETURN_FALSE; } tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); + obj = Z_TIDY_P(return_value); TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == FAILURE) { - zval_dtor(return_value); - INIT_ZVAL(*return_value); + if (php_tidy_parse_string(obj, input->val, input->len, enc TSRMLS_CC) == FAILURE) { + zval_ptr_dtor(return_value); RETURN_FALSE; } } @@ -1244,7 +1210,7 @@ static PHP_FUNCTION(tidy_get_error_buffer) TIDY_FETCH_OBJECT; if (obj->ptdoc->errbuf && obj->ptdoc->errbuf->bp) { - RETURN_STRINGL((char*)obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, 1); + RETURN_STRINGL((char*)obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1); } else { RETURN_FALSE; } @@ -1261,7 +1227,7 @@ static PHP_FUNCTION(tidy_get_output) tidyBufInit(&output); tidySaveBuffer(obj->ptdoc->doc, &output); FIX_BUFFER(&output); - RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0, 1); + RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0); tidyBufFree(&output); } /* }}} */ @@ -1270,36 +1236,35 @@ static PHP_FUNCTION(tidy_get_output) Parse markup in file or URI */ static PHP_FUNCTION(tidy_parse_file) { - char *inputfile, *enc = NULL; - int input_len, contents_len, enc_len = 0; + char *enc = NULL; + int enc_len = 0; zend_bool use_include_path = 0; - char *contents; - zval **options = NULL; + zend_string *inputfile, *contents; + zval *options = NULL; PHPTidyObj *obj; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|Zsb", &inputfile, &input_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|zsb", &inputfile, &options, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); + obj = Z_TIDY_P(return_value); - if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : ""); + if (!(contents = php_tidy_file_to_mem(inputfile->val, use_include_path TSRMLS_CC))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile->val, (use_include_path) ? " (Using include path)" : ""); RETURN_FALSE; } TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) { - zval_dtor(return_value); - INIT_ZVAL(*return_value); + if (php_tidy_parse_string(obj, contents->val, contents->len, enc TSRMLS_CC) == FAILURE) { + zval_ptr_dtor(return_value); RETVAL_FALSE; } - efree(contents); + STR_RELEASE(contents); } /* }}} */ @@ -1357,7 +1322,7 @@ static PHP_FUNCTION(tidy_get_release) return; } - RETURN_STRING((char *)tidyReleaseDate(), 1); + RETURN_STRING((char *)tidyReleaseDate()); } /* }}} */ @@ -1384,7 +1349,7 @@ static PHP_FUNCTION(tidy_get_opt_doc) } } - obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); + obj = Z_TIDY_P(object); opt = tidyGetOptionByName(obj->ptdoc->doc, optname); @@ -1394,7 +1359,7 @@ static PHP_FUNCTION(tidy_get_opt_doc) } if ( (optval = (char *) tidyOptGetDoc(obj->ptdoc->doc, opt)) ) { - RETURN_STRING(optval, 1); + RETURN_STRING(optval); } RETURN_FALSE; @@ -1547,7 +1512,7 @@ static PHP_FUNCTION(tidy_getopt) } } - obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); + obj = Z_TIDY_P(object); opt = tidyGetOptionByName(obj->ptdoc->doc, optname); @@ -1559,8 +1524,9 @@ static PHP_FUNCTION(tidy_getopt) optval = php_tidy_get_opt_val(obj->ptdoc, opt, &optt TSRMLS_CC); switch (optt) { case TidyString: - RETURN_STRING((char *)optval, 0); - break; + RETVAL_STRING((char *)optval); + efree(optval); + return; case TidyInteger: RETURN_LONG((long)optval); @@ -1585,88 +1551,89 @@ static PHP_FUNCTION(tidy_getopt) static TIDY_DOC_METHOD(__construct) { - char *inputfile = NULL, *enc = NULL; - int input_len = 0, enc_len = 0, contents_len = 0; + char *enc = NULL; + int enc_len = 0; zend_bool use_include_path = 0; - char *contents; - zval **options = NULL; + zval *options = NULL; + zend_string *contents, *inputfile = NULL; PHPTidyObj *obj; TIDY_SET_CONTEXT; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|pZsb", &inputfile, &input_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Pzsb", &inputfile, &options, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } - obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC); + obj = Z_TIDY_P(object); if (inputfile) { - if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : ""); + if (!(contents = php_tidy_file_to_mem(inputfile->val, use_include_path TSRMLS_CC))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile->val, (use_include_path) ? " (Using include path)" : ""); return; } TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC); + php_tidy_parse_string(obj, contents->val, contents->len, enc TSRMLS_CC); - efree(contents); + STR_RELEASE(contents); } } static TIDY_DOC_METHOD(parseFile) { - char *inputfile, *enc = NULL; - int input_len, enc_len = 0, contents_len = 0; + char *enc = NULL; + int enc_len = 0; zend_bool use_include_path = 0; - char *contents; - zval **options = NULL; + zval *options = NULL; + zend_string *inputfile, *contents; PHPTidyObj *obj; TIDY_SET_CONTEXT; - obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC); + obj = Z_TIDY_P(object); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|Zsb", &inputfile, &input_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|zsb", &inputfile, &options, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } - if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : ""); + if (!(contents = php_tidy_file_to_mem(inputfile->val, use_include_path TSRMLS_CC))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile->val, (use_include_path) ? " (Using include path)" : ""); RETURN_FALSE; } TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) { + if (php_tidy_parse_string(obj, contents->val, contents->len, enc TSRMLS_CC) == FAILURE) { RETVAL_FALSE; } else { RETVAL_TRUE; } - efree(contents); + STR_RELEASE(contents); } static TIDY_DOC_METHOD(parseString) { - char *input, *enc = NULL; - int input_len, enc_len = 0; - zval **options = NULL; + char *enc = NULL; + int enc_len = 0; + zval *options = NULL; PHPTidyObj *obj; + zend_string *input; TIDY_SET_CONTEXT; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|zs", &input, &options, &enc, &enc_len) == FAILURE) { RETURN_FALSE; } - obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC); + obj = Z_TIDY_P(object); TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == SUCCESS) { + if(php_tidy_parse_string(obj, input->val, input->len, enc TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } @@ -1829,7 +1796,7 @@ static TIDY_NODE_METHOD(getParent) parent_node = tidyGetParent(obj->node); if(parent_node) { tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - newobj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); + newobj = Z_TIDY_P(return_value); newobj->node = parent_node; newobj->type = is_node; newobj->ptdoc = obj->ptdoc; diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index f383603803..8b46910152 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -274,6 +274,7 @@ PS_SERIALIZER_ENCODE_FUNC(wddx) php_wddx_add_chunk_static(packet, WDDX_STRUCT_E); php_wddx_packet_end(packet); + smart_str_0(packet); str = STR_COPY(packet->s); php_wddx_destructor(packet); @@ -295,14 +296,20 @@ PS_SERIALIZER_DECODE_FUNC(wddx) return SUCCESS; } + ZVAL_UNDEF(&retval); if ((ret = php_wddx_deserialize_ex(val, vallen, &retval)) == SUCCESS) { ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(retval), idx, key, ent) { if (key == NULL) { key = STR_ALLOC(MAX_LENGTH_OF_LONG, 0); key->len = snprintf(key->val, key->len + 1, "%ld", idx); + } else { + STR_ADDREF(key); + } + if (php_set_session_var(key, ent, NULL TSRMLS_CC)) { + if (Z_REFCOUNTED_P(ent)) Z_ADDREF_P(ent); } - php_set_session_var(key, ent, NULL TSRMLS_CC); PS_ADD_VAR(key); + STR_RELEASE(key); } ZEND_HASH_FOREACH_END(); } @@ -599,6 +606,10 @@ void php_wddx_serialize_var(wddx_packet *packet, zval *var, zend_string *name TS STR_RELEASE(name_esc); } + if (Z_TYPE_P(var) == IS_INDIRECT) { + var = Z_INDIRECT_P(var); + } + ZVAL_DEREF(var); switch (Z_TYPE_P(var)) { case IS_STRING: php_wddx_serialize_string(packet, var TSRMLS_CC); @@ -908,7 +919,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) zend_str_tolower(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data)); STR_FORGET_HASH_VAL(Z_STR(ent1->data)); - if ((pce = zend_hash_find(EG(class_table), Z_STR(ent1->data))) == NULL) { + if ((pce = zend_hash_find_ptr(EG(class_table), Z_STR(ent1->data))) == NULL) { incomplete_class = 1; pce = PHP_IC_ENTRY; } @@ -937,8 +948,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) zend_class_entry *old_scope = EG(scope); EG(scope) = Z_OBJCE(ent2->data); - zval_ptr_dtor(&ent1->data); add_property_zval(&ent2->data, ent1->varname, &ent1->data); + if Z_REFCOUNTED(ent1->data) Z_DELREF(ent1->data); EG(scope) = old_scope; } else { zend_symtable_str_update(target_hash, ent1->varname, strlen(ent1->varname), &ent1->data); @@ -1079,7 +1090,8 @@ PHP_FUNCTION(wddx_serialize_value) php_wddx_packet_start(packet, comment, comment_len); php_wddx_serialize_var(packet, var, NULL TSRMLS_CC); php_wddx_packet_end(packet); - + smart_str_0(packet); + RETVAL_STR(STR_COPY(packet->s)); php_wddx_destructor(packet); } @@ -1184,10 +1196,11 @@ PHP_FUNCTION(wddx_packet_end) php_wddx_add_chunk_static(packet, WDDX_STRUCT_E); php_wddx_packet_end(packet); + smart_str_0(packet); RETVAL_STR(STR_COPY(packet->s)); - zend_list_delete(Z_RES_P(packet_id)); + zend_list_close(Z_RES_P(packet_id)); } /* }}} */ diff --git a/main/SAPI.c b/main/SAPI.c index 4cab4e54ea..49bd6ffbfc 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -458,7 +458,7 @@ SAPI_API void sapi_activate(TSRMLS_D) SG(request_info).post_entry = NULL; SG(request_info).proto_num = 1000; /* Default to HTTP 1.0 */ SG(global_request_time) = 0; - + SG(post_read) = 0; /* It's possible to override this general case in the activate() callback, if necessary. */ if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) { SG(request_info).headers_only = 1; diff --git a/tests/basic/bug67198.phpt b/tests/basic/bug67198.phpt index d28a292afa..9e2e224509 100644 --- a/tests/basic/bug67198.phpt +++ b/tests/basic/bug67198.phpt @@ -37,8 +37,6 @@ php_cli_server_start("exit(file_get_contents('php://input'));", false, "-d enabl var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context)); var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context)); ---XFAIL-- -67198 is open --EXPECT-- string(4) "PASS" string(4) "PASS" diff --git a/travis/compile.sh b/travis/compile.sh index 8b54b714ad..899fb5a335 100755 --- a/travis/compile.sh +++ b/travis/compile.sh @@ -9,7 +9,7 @@ if [[ "$ENABLE_DEBUG" == 1 ]]; then else DEBUG=""; fi -./buildconf +./buildconf --force ./configure --quiet \ $DEBUG \ $TS \ |