Commit Graph

80 Commits

Author SHA1 Message Date
Anatol Belski
5f9ae45e22 Fix test compatibility with libxml2 2.9.5 2017-09-11 12:12:19 +02:00
Joe Watkins
6bd30e8f1a
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix bug #74457 Wrong reflection on XMLReader::expand
2017-05-02 06:25:21 +01:00
Fabien Villepinte
4c0e50c88a
Fix bug #74457 Wrong reflection on XMLReader::expand 2017-05-02 06:24:46 +01:00
Christoph M. Becker
625e43caa8 Merge branch 'PHP-7.0' into PHP-7.1 2016-09-11 00:14:49 +02:00
Christoph M. Becker
8753356eb0 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-11 00:09:23 +02:00
Christoph M. Becker
326a4e38fb Add regression test for bug #73053
The test succeeds with libxml < 2.9.4, and is supposed to succeed with
libxml > 2.9.4. Unfortunately, we can't conditionally mark a test case
as XFAIL, so we're simply skipping the test for libxml 2.9.4 instead.
2016-09-11 00:06:45 +02: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
Anatol Belski
2d0081cebd Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  add test fo rbug 71805
2016-05-03 19:10:40 +02:00
Anatol Belski
5351151352 add test fo rbug 71805 2016-05-03 19:09:11 +02:00
Anatol Belski
f9ae74a4c0 make this test Windows only
as we're not in control of the libxml builds everywhere
2015-08-21 19:47:17 +02:00
Anatol Belski
13044447eb add test for bug 70309 2015-08-21 11:47:00 +02:00
Aaron Piotrowski
e97d5fab35 Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
Nikita Popov
3ae995f03c Tweak uncaught exception message display
This implements a reduced variant of #1226 with just the following
change:

-Fatal error: Uncaught exception 'EngineException' with message 'Call to private method foo::bar() from context ''' in %s:%d
+Fatal error: Uncaught EngineException: Call to private method foo::bar() from context '' in %s:%d

The '' wrapper around messages is very weird if the exception
message itself contains ''. Futhermore having the message wrapped
in '' doesn't work for the "and defined" suffix of
TypeExceptions.
2015-05-17 18:47:06 +02:00
Nikita Popov
c9f27ee422 Display EngineExceptions like ordinary exceptions
TypeException stays as-is for now because it uses messages that are
incompatible with the way exception messages are displayed.

closure_038.phpt and a few others now show that we're generating
too many exceptions for compound operations on undefined properties
-- this needs to be fixed in a followup.
2015-05-15 23:40:32 +02:00
Michael Wallner
f6ff3a28d6 Fixed bug #64230 (XMLReader does not suppress errors) 2013-10-04 11:22:17 +02:00
Michael Wallner
dc3d360a0f typo: really fix bug #51936 Crash with clone xmlreader 2013-10-03 13:34:31 +02:00
Michael Wallner
fc3f8a8f54 fix bug #59613 (Crash with clone XMLReader) 2013-10-03 13:28:41 +02:00
Xinchen Hui
2ce4bd7f2d Fix test typo 2013-06-19 11:15:52 +08:00
Stanislav Malyshev
6b896fa57f Merge branch 'pull-request/320'
* pull-request/320:
  this is test 5 not 6
  fix race condition
  more shared names that create race conditions
  change to a unique filename
  more shared filenames
  yet another shared filename
  don't share a filename to stop race conditions
  fix race condition for 2-4 and normalize names for others
  fix race condition when running tests in parallel
  clean up after test
  Fix #64572: Clean up after the test
  Fix #64572: Clean up after the test
2013-06-17 01:06:01 -07:00
Xinchen Hui
610c7fbe7b Remove executable permission on phpt 2012-10-10 10:27:49 +08:00
Olivier DOUCET
ce535f1819 more verbose skip reason in test files with not so obvious extension requirements 2012-02-25 12:10:41 +00:00
Pierre Joye
34eebd4f58 - fix test for OS where dir sep is \ 2011-09-07 09:19:28 +00:00
Rob Richards
37ba76d23d MFH: add parameter allowing node to be exported into existing Document context [DOC]
add test
fix warnings
2008-06-16 15:45:06 +00:00
Rob Richards
adb1cd835d MFH: fix bug #42139 (XMLReader option constants are broken using XML())
add test
2007-09-20 09:30:45 +00:00
Hannes Magnusson
aaa1d62614 MFH: fix/add SKIPIF 2006-06-27 00:09:43 +00:00
Rob Richards
aa38b5572e Synch with HEAD
add readInnerXML, readOuterXML, readString, and setSchema functionality
  allow parser options to be passed when loading reader
  optimization: use xmlTextReader const functions for string properties
  add test
2006-05-10 12:04:46 +00:00
Marcus Boerger
193ae05edd - MFH Add tests 2006-03-30 21:47:21 +00:00
Antony Dovgal
652d77eca4 fix #36743 (In a class extending XMLReader array properties are not writable) 2006-03-17 10:15:58 +00:00
Rob Richards
da692974ab MFH: fix tests 2006-01-04 19:44:46 +00:00
Pierre Joye
f90214347e - MFH: add tests, ~70% coverage 2005-12-21 03:58:59 +00:00