Commit Graph

383 Commits

Author SHA1 Message Date
Niels Dossche
b8840115ff
Shrink libxml_doc_props struct (#11326)
These values are only ever bools, store them as bools.
Reduces the size from 40 bytes to 16 bytes on my system.
2023-05-29 11:41:42 +02:00
Niels Dossche
82b05373b1 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11160: Few tests failed building with new libxml 2.11.0
2023-05-06 23:15:57 +02:00
Niels Dossche
dc1a70c244 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11160: Few tests failed building with new libxml 2.11.0
2023-05-06 23:10:58 +02:00
Niels Dossche
7c0dfc5cf5 Fix GH-11160: Few tests failed building with new libxml 2.11.0
It's possible to categorise the failures into 2 categories:
  - Changed error message. In this case we either duplicate the test and
    modify the error message. Or if the change in error message is
    small, we use the EXPECTF matchers to make the test compatible with both
    old and new versions of libxml2.
  - Missing warnings. This is caused by a change in libxml2 where the
    parser started using SAX APIs internally [1]. In this case the
    error_type passed to php_libxml_internal_error_handler() changed from
    PHP_LIBXML_ERROR to PHP_LIBXML_CTX_WARNING because it internally
    started to use the SAX handlers instead of the generic handlers.
    However, for the SAX handlers the current input stack is empty, so
    nothing is actually printed. I fixed this by falling back to a
    regular warning without a filename & line number reference, which
    mimicks the old behaviour. Furthermore, this change now also shows
    an additional warning in a test which was previously hidden.

[1] 9a82b94a94

Closes GH-11162.
2023-05-06 23:10:07 +02:00
Max Kellermann
1287747a9a
ext: make various internal functions static (#10650)
Namely in:
* ext/date
* ext/libxml
* ext/dba
* ext/curl
2023-02-21 15:51:41 +00:00
George Peter Banyard
32d3cae19f
Handle trampolines correctly in new FCC API + usages (#9877) 2022-11-22 17:12:53 +00:00
dwo0
9c6dd46f27
Skip tests if extension or SAPI is not included. (#9939)
* Skip test if SAPI is not enabled.
* Skip test if simplexml extension is disabled.
2022-11-11 21:17:15 -05:00
George Peter Banyard
fb114bf45b Only use FCC for libxml entity loader callback 2022-11-02 14:52:54 +00:00
Christoph M. Becker
ca011bbf56
Drop unsupported libxml2 2.10.0 symbols
The Docbook parser module has been removed completely.  Support for
XPointer locations (ranges and points) is disabled by default, and will
eventually be removed completely.  Given that the maintainer comments
on the latter: "Be warned that this part of the code base is buggy and
had many security issues in the past", it seems to be prudent to no
longer build with XPointer locations support right away.

To be able to build against libxml2 2.10.0, we remove the export
definitions for Windows.

Closes GH-9358.
2022-08-28 13:56:34 +02:00
Tim Starling
11796229f2
Add libxml_get_external_entity_loader()
Add libxml_get_external_entity_loader(), which returns the currently
installed external entity loader, i.e. the value which was passed to
libxml_set_external_entity_loader() or null if no loader was installed
and the default entity loader will be used.

This allows libraries to save and restore the loader, controlling entity
expansion without interfering with the rest of the application.

Add macro Z_PARAM_FUNC_OR_NULL_WITH_ZVAL(). This allows us to get the
zval for a callable parameter without duplicating callable argument
parsing.

The saved zval keeps the object needed for fcc/fci alive, simplifying
memory management.

Fixes #76763.
2022-08-28 12:47:20 +01:00
Máté Kocsis
b4ec3e9bc0
Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Christoph M. Becker
145525bc4c
Merge branch 'PHP-8.1'
* PHP-8.1:
  xmlRelaxNGCleanupTypes() is deprecated as of libxml2 2.10.0
2022-08-25 15:12:40 +02:00
Christoph M. Becker
afc5ab4531
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  xmlRelaxNGCleanupTypes() is deprecated as of libxml2 2.10.0
2022-08-25 15:11:41 +02:00
Christoph M. Becker
f59754694e
xmlRelaxNGCleanupTypes() is deprecated as of libxml2 2.10.0
The documentation[1] suggest to call `xmlCleanupParser()` instead, but
we are not doing that for reasons[2].  Thus, we do no longer call
`xmlRelaxNGCleanupTypes()` for libxml2 ≥ 2.10.0.

[1] <https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-relaxng.html#xmlRelaxNGCleanupTypes>
[2] <8742276eb3>

Closes GH-9417.
2022-08-25 15:10:30 +02:00
Máté Kocsis
e328c68305
Rename @cname to @cvalue in stubs (#9043)
@cname currently refers to the constant name in C. However, it is not always a (constant) name, but sometimes a function invocation, so naming it as @cvalue would be more appropriate.
2022-07-19 15:11:42 +02:00
Pierrick Charron
6fd2b39397
Indent with TAB in .h files generated by gen_stub 2022-06-13 08:55:54 -04:00
Máté Kocsis
7601068f3d
Declare ext/libxml constants in stubs (#8721) 2022-06-09 08:18:44 +02:00
Ilija Tovilo
2f5295692f
Optimize stripos/stristr
Closes GH-7847
Closes GH-7852

Previously stripos/stristr would lowercase both the haystack and the
needle to reuse strpos. The approach in this PR is similar to strpos.
memchr is highly optimized so we're using it to search for the first
character of the needle in the haystack. If we find it we compare the
remaining characters of the needle manually.

The new implementation seems to perform about half as well as strpos (as
two memchr calls are necessary to find the next candidate).
2022-01-31 21:44:31 +01:00
Nikita Popov
902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Stanislav Malyshev
9de4eb9e37
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #79971: special character is breaking the path in xml function
2021-11-14 23:29:59 -08:00
Stanislav Malyshev
9d74c5b40b
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #79971: special character is breaking the path in xml function
2021-11-14 23:29:37 -08:00
Stanislav Malyshev
0ef1dfc9f6
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79971: special character is breaking the path in xml function
2021-11-14 23:29:27 -08:00
Stanislav Malyshev
ca87d46a3e
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79971: special character is breaking the path in xml function
2021-11-14 23:28:13 -08:00
Christoph M. Becker
f15f8fc573
Fix #79971: special character is breaking the path in xml function
The libxml based XML functions accepting a filename actually accept
URIs with possibly percent-encoded characters.  Percent-encoded NUL
bytes lead to truncation, like non-encoded NUL bytes would.  We catch
those, and let the functions fail with a respective warning.
2021-11-14 23:24:33 -08:00
Máté Kocsis
6a47831e6e
Add more specific array return type hints for various extensions - part 3 (#7467) 2021-09-06 12:27:28 +02:00
Patrick Allaert
ac18dd0dc7 Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
Nikita Popov
7485978339
Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Nikita Popov
d818edeae2 Try to fix libxml 2.9.12 tests
The test expectations here were for PHP 8.0, try to adjust them
for PHP 7.4.
2021-06-02 12:21:45 +02:00
Nikita Popov
12a4b2249d Merge branch 'PHP-8.0'
* PHP-8.0:
  Make tests compatible with libxml2 2.9.12
2021-05-26 13:21:43 +02:00
Nikita Popov
0b232cf71d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Make tests compatible with libxml2 2.9.12
2021-05-26 13:20:36 +02:00
Stéphan Kochen
f3d1e9ed06 Make tests compatible with libxml2 2.9.12
This version of libxml introduced quite a few changes. Most of
them are differences in error reporting, while some also change
behavior, e.g. null bytes are no longer supported and xinclude
recursion is limited.

Closes GH-7030. Closes GH-7046.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-05-26 13:19:34 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Christoph M. Becker
6adec555db Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
2021-03-24 11:53:53 +01:00
Christoph M. Becker
5832be768c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
2021-03-24 11:52:54 +01:00
Christoph M. Becker
498eb8e052 Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
A string passed to `php_libxml_xmlCheckUTF8()` may be longer than
1<<31-1 bytes, so we're better using a `size_t`.

Closes GH-6802.
2021-03-24 11:50:50 +01:00
Christoph M. Becker
9f826e8ce9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #51903: simplexml_load_file() doesn't use HTTP headers
2021-03-08 15:16:55 +01:00
Christoph M. Becker
7931956805 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #51903: simplexml_load_file() doesn't use HTTP headers
2021-03-08 15:15:59 +01:00
Christoph M. Becker
f901bec494 Fix #51903: simplexml_load_file() doesn't use HTTP headers
The `encoding` attribute of the XML declaration is optional; it is good
practice to use external encoding information where available if it is
missing.  Thus, we check for `charset` info of `Content-Type` headers,
and see whether the encoding is supported.

We cater to trailing parameters and quoted-strings, but not to escaped
backslashes and quotes in quoted-strings, since no known character
encoding contains these anyway.

Co-authored-by: Michael Wallner <mike@php.net>

Closes GH-6747.
2021-03-08 15:07:01 +01:00
Máté Kocsis
cad66533f0
Generate class entries from stubs for ldap, libxml, mbstring and mysqli
Closes GH-6684
2021-02-16 14:46:19 +01:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Máté Kocsis
45fa7596dc
Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Máté Kocsis
99b08ac281
Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +01:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
42a6ff4201 Try to fix windows build 2020-09-03 15:07:03 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Dik Takken
e0fa48f69d Deprecate libxml_disable_entity_loader()
This method was used to protect code against XXE processing attacks.
Since PHP now requires libxml >= 2.9.0 external entity loading no longer
needs to be disabled to prevent these attacks. It is disabled by default.
Also, the method has an unwanted side effect that causes a lot of
confusion: Parsing XML data from resources like files is no longer possible.

Closes GH-5867.
2020-08-03 21:53:29 +02:00
Dik Takken
691a09f291 Bump libxml version requirement 2.7.6 => 2.9.0
Since libxml version 2.9.0 external entity loading is disabled by default.
Bumping the version requirement means that XML processing in PHP is no
longer vulnerable to XXE processing attacks by default.
2020-08-03 21:51:10 +02:00
Christoph M. Becker
24495ba778 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Enable libxml entity loader test case on Windows
2020-08-03 09:15:50 +02:00