Commit graph

92 commits

Author SHA1 Message Date
Niels Dossche
95d691ae00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-15168: stack overflow in json_encode()
2024-09-30 20:43:32 +02:00
Niels Dossche
a551b99b2c
Fix GH-15168: stack overflow in json_encode()
The JSON encoder is recursive, and it's far from easy to make it
iterative. Add a cheap stack limit check to prevent a segfault.
This uses the PHP_JSON_ERROR_DEPTH error code that already talks about
the stack depth. Previously this was only used for the $depth argument.

Closes GH-16059.
2024-09-30 20:42:01 +02:00
Arnaud Le Blanc
58aa6fc830
Lazy objects
RFC: https://wiki.php.net/rfc/lazy-objects

Closes GH-15019
2024-08-30 17:30:03 +02:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +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
fd2d869642
Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Gina Peter Banyard
efee76b8e2 ext/json: Fix sign conversion warnings 2024-06-08 17:15:01 +01:00
Jakub Zelenka
53aa53f42f
Introduce Zend guard recursion protection
This PR introduces a new way of recursion protection in JSON, var_dump
and friends. It fixes issue in master for __debugInfo and also improves
perf for jsonSerializable in some cases. More info can be found in
GH-10020.

Closes GH-11812
2023-08-24 13:03:14 +01:00
Jakub Zelenka
90553af15c
Merge branch 'PHP-8.1' into PHP-8.2 2023-05-13 18:53:35 +01:00
Jakub Zelenka
e8a836eb39
Expose JSON internal function to escape string 2023-05-13 18:41:33 +01:00
dixyes
3a843f953b
Windows arm64 zend and standard extension support
* Port zend_cpuid for windows arm64
* Fix zend_atomic windows arm64 build
* Fix windows arm64 multiply
* Enable arm64 neon for windows in standard extension
* Enable arm64 neon for windows in zend_hash.c
* Workaround for msvc arm64 optimization bug

Closes GH-9115.
2022-08-09 12:45:14 +02:00
George Peter Banyard
ec53e17adf
Use more appropriate types in JSON extension (#8194)
Mainly zend_result
2022-03-16 22:53:41 +00:00
George Peter Banyard
dd62ec065e
Refactor php_next_utf8_char() to use zend_result 2022-03-13 13:48:21 +00:00
Nikita Popov
6057cd2367 Fixed bug #81532 2021-10-18 12:41:27 +02:00
Nikita Popov
d28f6e694d Move php_gcvt to zend_gcvt
Also move PHP_DOUBLE_MAX_LENGTH to ZEND_DOUBLE_MAX_LENGTH.
2021-08-02 14:51:46 +02:00
Christoph M. Becker
d2cc7239b7
Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fix #79908: json_encode encodes negative zero as int"
2021-07-20 00:30:37 +02:00
Christoph M. Becker
18abfcb306
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Fix #79908: json_encode encodes negative zero as int"
2021-07-20 00:28:27 +02:00
Christoph M. Becker
2d2c001ca5
Revert "Fix #79908: json_encode encodes negative zero as int"
This reverts commit 717f1ed5e4.
2021-07-20 00:25:50 +02:00
Christoph M. Becker
5e0874f2a8
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #79908: json_encode encodes negative zero as int
2021-07-13 15:33:50 +02:00
Christoph M. Becker
1ba190bdb3
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79908: json_encode encodes negative zero as int
2021-07-13 15:32:32 +02:00
Christoph M. Becker
717f1ed5e4
Fix #79908: json_encode encodes negative zero as int
Encoding a negative zero as `-0` is likely to loose the sign when
decoding (at least it does with `json_decode()`).  Therefore, we encode
it as if `JSON_PRESERVE_ZERO_FRACTION` was specified, i.e. as `-0.0`.

Closes GH-7234.
2021-07-13 15:31:07 +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
Tyson Andre
92aeda524b Fix json_encode regression with JSON_PRETTY_PRINT
This makes the json encoding behavior the same as it was prior to the memory
optimizations added in f9f8c1c79c
(for objects with declared properties)

This is based on the code for the unoptimized case below the changes.

Buggy output prior to this commit:
```
{
"prop":"value"}
```

Correct output:

```
{
    "prop": "value"
}
```

Closes GH-6811
2021-03-27 18:47:54 -04:00
Ilija Tovilo
269c8dac1d
Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
Dmitry Stogov
f9f8c1c79c Optimized object encoding without rebulding properties HashTable 2021-03-01 22:37:05 +03:00
Dusk
13c430b1db Add array_is_list(array $array) function
This function tests if an array contains only sequential integer keys. While
list isn't an official type, this usage is consistent with the community usage
of "list" as an annotation type, cf.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists

Rebased and modified version of #4886

- Use .stub.php files
- Add opcache constant evaluation when argument is a constant
- Change from is_list(mixed $value) to array_is_list(array $array)

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

Co-Authored-By: Tyson Andre <tysonandre775@hotmail.com>
Co-Authored-By: Dusk <dusk@woofle.net>

Closes GH-6070
2021-01-20 18:53:48 -05:00
Nikita Popov
da0663a337 Add GC_TRY_ADDREF macro
That adds a ref if not immutable. Also audit uses of GC_IMMUTABLE
to either use GC_TRY_ADDREF or GC_TRY_PROTECT_RECURSION.
2020-09-15 11:41:09 +02:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Nikita Popov
eb7d57eb77 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-23 12:43:37 +02:00
Nikita Popov
68892410f7 Merge branch 'PHP-7.2' into PHP-7.3 2019-04-23 12:43:32 +02:00
Nikita Popov
4831e150c5 Fixed bug #77843 2019-04-23 12:43:07 +02:00
Dmitry Stogov
46d5551fc3 Optimization for ASCII data 2019-03-18 19:33:51 +03:00
c9s
9f6f6fe219 Remove function_table var from the caller
function_table var is not used in call_user_function macro anymore
hence replace the usage with NULL
2019-03-11 10:00:39 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Nikita Popov
7ec8087f80 Introduce get_properties_for() handler
This handler allows getting the object properties for a particular
purpose, such as array casting, serialization, etc.
2018-10-10 10:39:10 +02:00
Dmitry Stogov
c1ce43d1d2 php_json_escape_string() optimization 2018-06-13 18:26:48 +03:00
Dmitry Stogov
d90c6f2443 Removed useless zval_ptr_dtor() 2018-05-29 17:58:06 +03:00
Dmitry Stogov
4ad9cf4605 Bit test optimization 2018-05-08 11:58:17 +03:00
Dmitry Stogov
c88be6aee1 Bit check micro-optimization 2018-04-28 14:13:12 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Jakub Zelenka
d1f5811ff0 Merge branch 'PHP-7.2' 2017-10-15 19:37:22 +01:00
Jakub Zelenka
7c556c44a1 Fix bug #68567 (JSON_PARTIAL_OUTPUT_ON_ERROR can result in JSON with null key) 2017-10-15 19:36:15 +01:00
Dmitry Stogov
cb9d81ef4f Refactored recursion pretection 2017-10-06 01:34:50 +03:00
Jakub Zelenka
0f047f60f0 [ci skip] Remove CSV leftovers from json code - $Id$ 2017-07-16 15:51:39 +01:00
Jakub Zelenka
0d0f7cde8c Add JSON_INVALID_UTF8_SUBSTITUTE and JSON_INVALID_UTF8_IGNORE
It implements request #65082 and adds options for replacing resp.
ignoring invalid UTF-8 sequences for json_encode and json_decode.
2017-07-16 12:35:24 +01:00
Dmitry Stogov
6fe75aad6d Optimization for fast path. 2017-06-19 10:07:11 +03:00
Dmitry Stogov
1385784f54 Fixed performance degradaton introduced in f6ac96b 2017-06-13 12:20:14 +03:00