Commit graph

936 commits

Author SHA1 Message Date
Niels Dossche
ec10b28d64 Fix array overrun when appending slash to paths
Fix it by extending the array sizes by one character. As the input is
limited to the maximum path length, there will always be place to append
the slash. As the php_check_specific_open_basedir() simply uses the
strings to compare against each other, no new failures related to too
long paths are introduced.
We'll let the DOM and XML case handle a potentially too long path in the
library code.
2023-02-12 20:56:19 -07:00
NathanFreeman
6027d441c1
Fix #79451: DOMDocument->replaceChild on doctype causes double free
We have to reset intSubset if replacing doctype with another doctype node.

Closes GH-9201.
Closes GH-9376.
2022-08-19 18:10:06 +02:00
George Peter Banyard
d6831e9a5c Revert Fixed bug #79451
The fix for 8.1 and above is not identical and I don't know how to fix without breaking the whole build apparently
2022-08-19 13:54:54 +01:00
NathanFreeman
1d4300d870 Fix bug #79451: Using DOMDocument->replaceChild on doctype causes double free
Closes GH-9201
2022-08-19 12:46:23 +01: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
Nikita Popov
decf906a90 Remove bug76738.phpt
The test contains PII in the base64-encoded part and is way too
complicated to be useful. I'd try to reduce it, but I can't tell
what it's actually supposed to test.
2021-10-21 10:40:12 +02:00
Christoph M. Becker
6fbdf69628
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
2021-09-13 12:13:09 +02:00
Viktor
424c265478
Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
We must only remove the attribute id, if the user requested that.

Closes GH-7482.
2021-09-13 12:11:36 +02:00
Máté Kocsis
ee11a6065c
Fix DOMNameSpaceNode casing 2021-08-05 09:02:31 +02:00
Nikita Popov
a0893865b3 dom_import_simplexml() cannot return null 2021-07-21 11:13:37 +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
Christoph M. Becker
fddd0ac552 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #66783: UAF when appending DOMDocument to element
2021-03-17 12:40:03 +01:00
Christoph M. Becker
a08847ab39 Fix #66783: UAF when appending DOMDocument to element
According to the DOM standard, elements may only contain element, text,
processing instruction and comment nodes[1].  It is also specified that
a HierarchyRequestError should be thrown if a document is to be
inserted[2].  We follow that standard, and prevent the use-after-free
this way.

[1] <https://dom.spec.whatwg.org/#node-trees>
[2] <https://dom.spec.whatwg.org/#mutation-algorithms>

Closes GH-6765.
2021-03-17 12:37:18 +01:00
Máté Kocsis
5ecc078a17
Add missing skipif sections to ext/dom tests 2021-03-15 23:45:37 +01:00
Nikita Popov
44ef32ff2c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix potential file collision in dom tests
2021-02-24 21:30:44 +01:00
Nikita Popov
766f827e26 Fix potential file collision in dom tests 2021-02-24 21:30:20 +01:00
Máté Kocsis
45fa7596dc
Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Nikita Popov
3549f48edc Make createDocument() $namespace nullable
According to the DOM specification, this argument should be
nullable. It's also supposed to be a required argument, but
not changing that at this point.
2021-02-09 12:28:28 +01:00
Nikita Popov
ab92ffee22 Make getElementsByTagNameNS $namespace nullable
According to the DOM specification, this argument is supposed to
be nullable.
2021-02-09 12:19:44 +01:00
Benjamin Eberlei
665e1f324a Fix bug #80600 DOMChildNode::remove does not work on DOMCharacterData.
Closes GH-6660
2021-02-02 20:26:52 +01:00
Máté Kocsis
9cec093b7f
Add support for generating methodsynopses from stubs
Closes GH-6367
2020-12-28 14:44:43 +01:00
Nikita Popov
27e250880b Fix bug #80537
This is an unavoidable breaking change to both the type and
parameter name.

The assertion that was supposed to prevent this was overly lax
and accepted any object type for string parameters.
2020-12-21 10:21:50 +01:00
Christoph M. Becker
e71036ce03 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80268: loadHTML() truncates at NUL bytes
2020-10-26 13:15:03 +01:00
Christoph M. Becker
7bc1c0cca8 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80268: loadHTML() truncates at NUL bytes
2020-10-26 13:09:30 +01:00
Christoph M. Becker
6d2bc72530 Fix #80268: loadHTML() truncates at NUL bytes
libxml2 has no particular issues parsing HTML strings with NUL bytes;
these just cause truncation of the current text content, but parsing
continues generally.  Since `::loadHTMLFile()` already supports NUL
bytes, `::loadHTML()` should as well.

Note that this is different from XML, which does not allow any NUL
bytes.

Closes GH-6368.
2020-10-26 13:08:05 +01:00
Dik Takken
f3c58a5ed6 Make handling of NULL bytes in file paths more consistent (WIP)
Not all extensions consistently throw exceptions when the user passes
a path name containing null bytes. Also, some extensions would throw
a ValueError while others would throw a TypeError. Error messages
also varied.

Now a ValueError is thrown after all failed path checks, at least for
as far as these occur in functions that are exposed to userland.

Closes GH-6216.
2020-09-29 14:55:10 +02:00
Máté Kocsis
72e8719ed0
Fix a few ZEND_UNREACHABLE() calls 2020-09-23 10:07:58 +02:00
George Peter Banyard
8fef83dd3c Promote warnings to error in DOM extension
Closes GH-5418
2020-09-22 19:12:32 +01:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Máté Kocsis
c76910cd96
Display types in stubs more uniformly
In preparation for generating method signatures for the manual.

This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types.
2020-09-16 21:19:36 +02:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Benjamin Eberlei
9f6820f7f1 Fix #79968: Manipulation on unattached DOMChildNode should throw DOMException 2020-08-19 11:54:41 +02:00
Máté Kocsis
2803c8fb8d
Add all the missing parameter types to stubs
Closes GH-5955
2020-08-13 14:47:18 +02:00
Nikita Popov
634dd38289 Throw Error exception in DOM_GET_OBJ
Per general convention for handling of uninitialized objects.
2020-08-13 14:43:40 +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
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Benjamin Eberlei
8a6bc6767d Consolidate Parameter Names For ext/dom
Co-authored-by: Thomas Weinert <thomas@weinert.info>
2020-07-27 21:42:33 +02:00
Nikita Popov
d625c29df7 Remove spurious return true from DOMXPath::registerPhpFunctions()
Only one of three identical cases returned true, and the function
is documented to return void. Remove the outlier.
2020-07-17 16:11:30 +02:00
Nikita Popov
d449d1dbbf Use string|array type in DOMXPath::registerPhpFunctions() 2020-07-17 16:10:49 +02:00
Nikita Popov
70501b81a7 Fixed bug #79852 2020-07-14 12:31:06 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Nikita Popov
632766a561 Disallow separation in a number of callbacks
All of these clearly do not need separation support.
2020-07-07 09:02:24 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
312201dce4 Add get_gc handle for object iterators
Optional handler with the same semantics as the object handler.
2020-07-01 15:17:22 +02:00