Commit Graph

559 Commits

Author SHA1 Message Date
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Anatol Belski
a5e9a73db2 fix typo
(cherry picked from commit efc1f33b58)
2016-10-14 01:43:54 +02:00
Stanislav Malyshev
e7e60851ae Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML()
(cherry picked from commit 96a8cf8e1b)
(cherry picked from commit 4ef79370a8)
2016-10-14 01:42:05 +02:00
Christoph M. Becker
7d80b64ac8 Merge branch 'PHP-7.0' into PHP-7.1 2016-09-09 16:32:27 +02:00
Christoph M. Becker
7a90fc96d8 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-09 16:30:26 +02:00
Christoph M. Becker
c42a7f2f3f Remove ignored --FAIL-- section from test case
This is just confusing.
2016-09-09 16:27:50 +02:00
Nikita Popov
d49024c6de Merge branch 'PHP-7.0' into PHP-7.1 2016-08-30 13:06:32 +02:00
Nikita Popov
bfd4277008 Fix bug #72957 2016-08-30 13:05:53 +02:00
Nikita Popov
6adb7e0b7a Followup for bug #72971
Property writes did not respect the namespace either. This is an
incomplete fix in that it only handles the case where an existing
child element is modified, not when a new one is created.
2016-08-30 12:53:50 +02:00
Nikita Popov
51a564e505 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-30 10:56:06 +02:00
Nikita Popov
07cc6a6ba2 Fix bug #72971 2016-08-30 10:54:31 +02:00
Nikita Popov
735bec4f40 Avoid uncollectable cycle in sxe_property_get_adr
The code was storing the created object in a property on the
created object, creating a trivial cycle. This cycle cannot be
collected (even if sxe->tmp is exposed via get_gc), because it
is never rooted (and we cannot safely manually root it).

Change the code to store the created object on the parent node
instead.

The only reason this is not showing up as a leak is that sxe->tmp
is dtor'ed in the dtor handler, which means that these objects
do get collected on shutdown -- but never earlier.
2016-07-16 23:43:24 +02:00
Nikita Popov
2c51a2d00b Remove unnecessary use of sxe->tmp 2016-07-16 23:16:51 +02:00
Xinchen Hui
f24ed8c2fe Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72588 (Using global var doesn't work while accessing SimpleXML element)
2016-07-13 10:50:15 +08:00
Xinchen Hui
8129b83992 Fixed bug #72588 (Using global var doesn't work while accessing SimpleXML element) 2016-07-13 10:49:58 +08:00
Aaron Piotrowski
24237027bc Merge branch 'throw-error-in-extensions' 2016-07-05 02:08:39 -05:00
Dmitry Stogov
323b2733f6 Fixed compilation warnings 2016-06-22 00:40:50 +03:00
Dmitry Stogov
1616038698 Added ZEND_ATTRIBUTE_FORMAT to some middind functions.
"%p" replaced by ZEND_LONG_FMT to avoid compilation warnings.
Fixed most incorrect use cases of format specifiers.
2016-06-21 16:00:37 +03:00
Anatol Belski
3d3f11ede4 Fixed the UTF-8 and long path support in the streams on Windows.
Since long the default PHP charset is UTF-8, however the Windows part is
out of step with this important point. The current implementation in PHP
doesn't technically permit to handle UTF-8 filepath and several other
things. Till now, only the ANSI compatible APIs are being used. Here is more
about it

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317752%28v=vs.85%29.aspx

The patch fixes not only issues with multibyte filenames under
incompatible codepages, but indirectly also issues with some other multibyte
encodings like BIG5, Shift-JIS, etc. by providing a clean way to access
filenames in UTF-8. Below is a small list of issues from the bug tracker,
that are getting fixed:

https://bugs.php.net/63401
https://bugs.php.net/41199
https://bugs.php.net/50203
https://bugs.php.net/71509
https://bugs.php.net/64699
https://bugs.php.net/64506
https://bugs.php.net/30195
https://bugs.php.net/65358
https://bugs.php.net/61315
https://bugs.php.net/70943
https://bugs.php.net/70903
https://bugs.php.net/63593
https://bugs.php.net/54977
https://bugs.php.net/54028
https://bugs.php.net/43148
https://bugs.php.net/30730
https://bugs.php.net/33350
https://bugs.php.net/35300
https://bugs.php.net/46990
https://bugs.php.net/61309
https://bugs.php.net/69333
https://bugs.php.net/45517
https://bugs.php.net/70551
https://bugs.php.net/50197
https://bugs.php.net/72200
https://bugs.php.net/37672

Yet more related tickets can for sure be found - on bugs.php.net, Stackoverflow
and Github. Some of the bugs are pretty recent, some descend to early
2000th, but  the user comments in there last even till today. Just for example,
bug #30195 was opened in 2004, the latest comment in there was made in 2014. It
is certain, that these bugs descend not only to pure PHP use cases, but get also
redirected from the popular PHP based projects. Given the modern systems (and
those supported by PHP) are always based on NTFS, there is no excuse to keep
these issues unresolved.

The internalization approach on Windows is in many ways different from
UNIX and Linux, while it supports and is based on Unicode. It depends on the
current system code page, APIs used and exact kind how the binary was compiled
The locale doesn't affect the way Unicode or ANSI API work. PHP in particular
is being compiled without _UNICODE defined and this is conditioned by the
way we handle strings. Here is more about it

https://msdn.microsoft.com/en-us/library/tsbaswba.aspx

However, with any system code page ANSI functions automatically convert
paths to UTF-16. Paths in some encodings incompatible with the
current system code page, won't work correctly with ANSI APIs. PHP
till now only uses the ANSI Windows APIs.

For example, on a system with the current code page 1252, the paths
in cp1252 are supported and transparently converted to UTF-16 by the
ANSI functions. Once one wants to handle a filepath encoded with cp932 on
that particular system, an ANSI or a POSIX compatible function used in
PHP will produce an erroneous result. When trying to convert that cp932 path
to UTF-8 and passing to the ANSI functions, an ANSI function would
likely interpret the UTF-8 string as some string in the current code page and
create a filepath that represents every single byte of the UTF-8 string.
These behaviors are not only broken but also disregard the documented
INI settings.

This patch solves the issies with the multibyte paths on Windows by
intelligently enforcing the usage of the Unicode aware APIs. For
functions expect Unicode (fe CreateFileW, FindFirstFileW, etc.), arguments
will be converted to UTF-16 wide chars. For functions returning Unicode
aware data (fe GetCurrentDirectoryW, etc.), resulting wide string is
converted back to char's depending on the current PHP charset settings,
either to the current ANSI codepage (this is the behavior prior to this patch)
or to UTF-8 (the default behavior).

In a particular case, users might have to explicitly set
internal_encoding or default_charset, if filenames in ANSI codepage are
necessary. Current tests show no regressions and witness that this will be an
exotic case, the current default UTF-8 encoding is compatible with any
supported system. The dependency libraries are long switching to Unicode APIs,
so some tests were also added for extensions not directly related to streams.
At large, the patch brings over 150 related tests into the core. Those target
and was run on various environments with European, Asian, etc. codepages.
General PHP frameworks was tested and showed no regressions.

The impact on the current C code base is low, the most places affected
are the Windows only places in the three files tsrm_win32.c, zend_virtual_cwd.c
and plain_wrapper.c. The actual implementation of the most of the wide
char supporting functionality is in win32/ioutil.* and win32/codepage.*,
several  low level functionsare extended in place to avoid reimplementation for
now. No performance impact was sighted. As previously mentioned, the ANSI APIs
used prior the patch perform Unicode conversions internally. Using the
Unicode  APIs directly while doing custom conversions just retains the status
quo. The ways to optimize it are open (fe. by implementing caching for the
strings converted to wide variants).

The long path implementation is user transparent. If a path exceeds the
length of _MAX_PATH, it'll be automatically prefixed with \\?\. The MAXPATHLEN
is set to 2048 bytes.

Appreciation to Pierre Joye, Matt Ficken, @algo13 and others for tips, ideas
and testing.

Thanks.
2016-06-20 12:45:39 +02:00
Aaron Piotrowski
771e5cc247 Replace zend_ce_error with NULL and replace more E_ERROR with thrown Error 2016-06-13 09:02:17 -05:00
Aaron Piotrowski
e3c681aa5c Merge branch 'master' into throw-error-in-extensions 2016-06-10 22:02:23 -05:00
Anatol Belski
58c82ff0b0 Merge branch 'PHP-7.0'
* PHP-7.0:
  fix regression introduced in 5683b6fa39
2016-03-08 13:16:46 +01:00
Anatol Belski
7a4c2fa829 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  fix regression introduced in 5683b6fa39
2016-03-08 13:16:08 +01:00
Anatol Belski
8ca02bb233 fix regression introduced in 5683b6fa39
Test extended. Basically, both iterator type and next node have
to be checked.
2016-03-08 12:59:59 +01:00
Nikita Popov
2eb4728611 Remove HAVE_SPL checks
SPL is always built.

Also clean up spl_ce_RuntimeException handling in PDO.
2016-01-30 14:53:00 +01:00
Lior Kaplan
ed35de784f Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Happy new year (Update copyright to 2016)
2016-01-01 19:48:25 +02:00
Lior Kaplan
49493a2dcf Happy new year (Update copyright to 2016) 2016-01-01 19:21:47 +02:00
Anatol Belski
a3dceb485a fix test 2015-08-26 16:39:48 +02:00
Anatol Belski
2c523f21c9 add range checks to simplexml 2015-08-26 16:39:47 +02:00
Christoph M. Becker
8d31e463a0 fixed test 2015-08-01 23:52:35 +02:00
Nikita Popov
36e49c702b Fix simplexml warnings 2015-07-17 21:12:15 +02:00
Aaron Piotrowski
7ec1e17464 Update memory freeing and other issues, revert some changes 2015-07-05 23:25:53 -05:00
Aaron Piotrowski
907476f34c Convert E_ERROR to thrown Error in extensions 2015-07-05 12:16:57 -05:00
Aaron Piotrowski
ed1b64877d Switch position of ce in exception ce variable names 2015-07-03 09:45:03 -05:00
Aaron Piotrowski
a812a74c2e Change zend_exception_get_default() to zend_exception_ce 2015-07-03 09:44:48 -05:00
Dmitry Stogov
6daed13c8b Cleanup (removed dead code) 2015-07-01 22:18:40 +03:00
Dmitry Stogov
4bd22cf1c1 Improved zend_string API (Francois Laupretre)
Squashed commit of the following:

commit d96eab8d79
Author: Francois Laupretre <francois@tekwire.net>
Date:   Fri Jun 26 01:23:31 2015 +0200

    Use the new 'ZSTR' macros in the rest of the code.

    Does not change anything to the generated code (thanks to compat macros) but cleaner.

commit b352643910
Author: Francois Laupretre <francois@tekwire.net>
Date:   Thu Jun 25 13:45:06 2015 +0200

    Improve zend_string API

    Add missing methods
2015-06-29 16:44:54 +03:00
Rasmus Lerdorf
28d7bb97a1 Fix more proto comments 2015-06-23 17:46:20 -04:00
Aaron Piotrowski
77cf6d81b4 Fix some missed tests 2015-06-15 08:20:30 -05:00
Aaron Piotrowski
110e0a5a2c Merge branch 'master' into throwable-interface
# Conflicts:
#	Zend/zend_language_scanner.c
#	Zend/zend_language_scanner.l
#	ext/simplexml/tests/SimpleXMLElement_xpath.phpt
2015-06-14 18:53:11 -05:00
Dmitry Stogov
1c754f0b71 Get rid of more ZVAL_ZVAL() macros 2015-06-12 13:33:14 +03:00
Dmitry Stogov
8e10e8f921 Avoid zval duplication in ZVAL_ZVAL() macro (it was necessary only in few places).
Switch from ZVAL_ZVAL() to simpler macros where possible (it makes sense to review remaining places)
2015-06-12 12:33:23 +03:00
Nikita Popov
5d3cf577aa Make convert_to_* safe with rc>1
This only involves switching zval_dtor to zval_ptr_dtor for arrays
and making the convert_to_object for arrays a bit more generic.

All the other changes outside zend_operators.c just make use of
this new ability (use COPY instead of DUP).

What's still missing: Proper references handling. I've seen many
convert_to* calls that will break when a reference is used.

Also fixes bug #69788.
2015-06-11 23:23:57 +02:00
Christoph M. Becker
c1401ad7b6 split simplexml tests for 7 2015-05-31 21:35:21 +02:00
Anatol Belski
6f1c006b6d Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  split the original test to check behaviour diff on 32- and 64-bit
  recovered original meaning of SXE xpath test
2015-05-31 21:30:46 +02:00
Christoph M. Becker
b24fedbd24 split the original test to check behaviour diff on 32- and 64-bit 2015-05-31 21:28:44 +02:00
Christoph M. Becker
e44b040faf recovered original meaning of SXE xpath test 2015-05-31 21:27:02 +02:00
Anatol Belski
8e02be16d7 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Refactored the fix for bug #66084, by cmb@php.net
  Merge the fix for #69703 to 5.5 per request from Julien
2015-05-29 21:18:04 +02:00
Anatol Belski
5683b6fa39 Refactored the fix for bug #66084, by cmb@php.net 2015-05-29 21:16:56 +02:00
Christoph M. Becker
36eb66692c removed test for unrelated bug #68946 2015-05-29 20:43:40 +02:00