Commit graph

267 commits

Author SHA1 Message Date
Niels Dossche
cec079ee72
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in tidy output handler on error
  Fix leaks with multiple calls to DatePeriod iterator current()
2025-05-26 19:42:39 +02:00
Niels Dossche
06f592820d
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in tidy output handler on error
  Fix leaks with multiple calls to DatePeriod iterator current()
2025-05-26 19:42:20 +02:00
Niels Dossche
b39e17b06c
Fix memory leak in tidy output handler on error
Closes GH-18649.
2025-05-26 19:41:11 +02:00
David CARLIER
caf0a5352a
ext/tidy: simplify tidy_instantiate (#18647) 2025-05-25 10:41:16 +01:00
David CARLIER
0c2025cdc4
ext/tidy: array optimisations, children node arrays as packed. (#18375) 2025-04-21 13:47:53 +01:00
Niels Dossche
ad452086d9
Add tidyNode::getNextSibling() and tidyNode::getPreviousSibling()
These get the next and previous sibling nodes, respectively.
We can already kind of do this by using the $child array, but that's
inconvenient when actually walking the tree by only using node
instances. Since the class is final, there is no BC break here.

Closes GH-15047.
2024-07-25 13:55:20 +02:00
Niels Dossche
9b78e5ff1c Remove useless return 2024-07-21 18:36:19 +02:00
Niels Dossche
186788f149 Fix error handling in tidy constructor 2024-07-21 18:36:19 +02:00
Niels Dossche
1d045a5c97 Use RETVAL_BOOL or RETURN_BOOL in ext/tidy 2024-07-21 18:36:19 +02:00
Niels Dossche
09c0455f64 Consistently check zend_result in the same way 2024-07-21 18:36:19 +02:00
Niels Dossche
e736d7cd8a Make more pointers const in ext/tidy 2024-07-21 18:36:19 +02:00
Niels Dossche
c4e1f2b4e8
Factor out object creation code in ext/tidy 2024-07-21 17:01:47 +02:00
Niels Dossche
d14b936d4f
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix memory leaks in ext/tidy basedir restriction code
2024-07-21 16:28:51 +02:00
Niels Dossche
8de7ccb29b
Fix memory leaks in ext/tidy basedir restriction code
TIDY_APPLY_CONFIG can early return because it's a macro, but then the
cleanup paths are not executed. Transform this to a real function and
handle the cleanups correctly at the callsites.

Closes GH-15046.
2024-07-21 16:28:15 +02:00
Niels Dossche
c695b1dc88
Improve error message for too long file in ext/tidy (#14870)
As suggested in https://github.com/php/php-src/pull/14862#discussion_r1667788025
2024-07-08 15:06:57 +02:00
Niels Dossche
0b3c506b18
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix memory leak in tidy_repair_file()
2024-07-08 13:31:25 +02:00
Niels Dossche
c34def581a
Fix memory leak in tidy_repair_file()
When dealing with a file, we must free the contents if the function
fails. While here, also fix the error message because previously it
sounded like the filename was too long while in fact the file itself
is too large.

Closes GH-14862.
2024-07-08 13:24:32 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Gina Peter Banyard
2447cb25c6
main/output.c: Refine int return type to bool or zend_result (#13997) 2024-04-19 10:46:40 +01:00
Arnaud Le Blanc
fd73681c86
Fix GCC warning when using getThis() in a conditional (#13923)
Since GCC 12.x, using getThis() in a conditional yields a warning:

    <source>:12:22: warning: the comparison will always evaluate as 'true' for
                    the address of 'This' will never be NULL [-Waddress]
       12 |     return getThis() ? 2 : 3;
          |                      ^
2024-04-09 19:09:07 +02:00
Niels Dossche
b3f483db2e Fix GH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
Closes GH-12993.
2023-12-22 17:37:34 +01:00
George Peter Banyard
0f394ecbe8
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect error check in browsecap for pcre2_match()
  Add missing error check on tidyLoadConfig
2023-02-21 14:13:35 +00:00
ndossche
f592f75e9c
Add missing error check on tidyLoadConfig
Parse errors were not reported for the default config, they were only
reported when explicitly another config was loaded.
This means that users may not be aware of errors in their configuration
and therefore the behaviour of Tidy might not be what they intended.
This patch fixes that issue by using a common function. In fact, the
check for -1 might be enough for the current implementation of Tidy, but
the Tidy docs say that any value other than 0 indicates an error.
So future errors might not be caught when just using an error code of -1.
Therefore, this also changes the error code checks of == -1 to < 0 and
== 1 to > 0.

Closes GH-10636

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 14:12:17 +00:00
George Peter Banyard
d8cec14c11
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix memory leaks in ext-tidy
2023-02-10 14:16:38 +00:00
George Peter Banyard
704aadd098
Fix memory leaks in ext-tidy
We must not instantiate the object prior checking error conditions
Moreover, we need to release the HUGE amount of memory for files which are over 4GB when throwing a ValueError

Closes GH-10545
2023-02-10 14:12:23 +00:00
George Peter Banyard
1ad59b32c2 Update INI validator and displayers depending on INI type
Closes GH-9451
2022-09-06 10:33:34 +01:00
Máté Kocsis
d7383ed807
Declare ext/tidy constants in stubs (#9383) 2022-08-20 17:08:28 +02:00
Ilija Tovilo
3b92a96610
Convert return type of various object handlers from int to zend_result (#8755) 2022-06-26 01:00:19 +02:00
Máté Kocsis
aeb4acacec Declare tidyNode properties as readonly 2022-05-26 08:26:16 +02:00
Máté Kocsis
768d00f83b Declare tidy properties 2022-05-26 08:26:16 +02:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +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
09efad615b
Use zend_string_equals_(literal_)ci() API more often
Also drive-by usage of zend_ini_parse_bool()

Closes GH-6844
2021-04-09 02:34:50 +01:00
Máté Kocsis
a730dc0cf9
Generate class entries for snmp, soap, sockets, sodium, sqlite3, sysv*, tidy
Closes GH-6696
2021-02-15 11:45:26 +01:00
Nikita Popov
c8f809fcff Remove unnecessary TRUE/FALSE defines in tidy
Instead use standard true/false.
2021-01-25 15:54:15 +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
Christoph M. Becker
ce3ff8ec7d php_tidy_create_node() expects a fixed set of node_types
This static function is not supposed to deal with arbitrary
`node_type`s, so there is no need to do so.

Closes GH-6467.
2020-11-30 10:29:46 +01:00
Christoph M. Becker
9b1c02c2df Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #77594: ob_tidyhandler is never reset
2020-11-22 14:04:59 +01:00
Christoph M. Becker
221345a013 Fix #77594: ob_tidyhandler is never reset
We reset to original INI value on request shutdown.

Closes GH-6425.
2020-11-22 14:02:29 +01:00
Nikita Popov
6de6f2a4e9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Don't crash on uninitialized tidy object
2020-10-22 16:05:57 +02:00
Nikita Popov
85d9a1ca6e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Don't crash on uninitialized tidy object
2020-10-22 16:05:34 +02:00
Nikita Popov
d4bf0799b8 Don't crash on uninitialized tidy object
"Uninitialized" here means that the object was created ordinarily
-- no constructor skipping involved. Most tidy methods seem to
handle this fine, but these three need to be guarded.
2020-10-22 16:04:22 +02:00
Christoph M. Becker
c774619118 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #77040: tidyNode::isHtml() is completely broken
2020-10-07 17:50:24 +02:00
Christoph M. Becker
ff3878adeb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77040: tidyNode::isHtml() is completely broken
2020-10-07 17:48:12 +02:00
Christoph M. Becker
e68acd031d Fix #77040: tidyNode::isHtml() is completely broken
The documentation of `tidyNode::isHtml()` states that this method
"checks if a node is part of a HTML document".  That is, of course,
nonsense, since a tidyNode is "an HTML node in an HTML file, as
detected by tidy."

What this method is actually supposed to do is to check whether a node
is an element (unless it is the root element).  This has been broken by
commit d8eeb8e[1], which assumed that `enum TidyNodeType` would
represent flags of a bitmask, what it does not.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=d8eeb8e28673236bca3f066ded75037a5bdf6378>

Closes GH-6290.
2020-10-07 17:43:56 +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
628db3f3b5
Fix UNKNOWN default values in various extensions
Closes GH-6075
2020-09-07 19:02:02 +02:00
Máté Kocsis
f7fbc6333f
Add more precise type info for stubs
Closes GH-6005
2020-09-01 16:35:56 +02:00
Máté Kocsis
7476d2c188
Promote warnings to exceptions in ext/tidy
Closes GH-6051
2020-09-01 14:18:02 +02:00