Commit graph

1308 commits

Author SHA1 Message Date
Máté Kocsis
8107a1da5a
Use ZPP instead of custom type checks
We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
2020-09-04 14:32:34 +02:00
Nikita Popov
ce83ec8790 Clean up strtok implementation
Store the zend_string instead of performing a copy and storing
in a zval. Also make sure the string is released immediately if
it's no longer needed. Finally, avoid null pointer offset UB if
no string has been set -- though I'm wondering if this case
shouldn't be generating a warning?
2020-08-27 12:24:58 +02:00
Nikita Popov
c557c410af Drop a spurious zend_string_release
This should have been dropped in the refactoring.
2020-08-24 17:30:31 +02:00
Nikita Popov
9feb98859f Clean up setlocale implementation
Factor out the core logic into a separate function and drop the
"clever" code that combines iteration through variadic arguments
and arrays.

This fixes bug #79829 as a side effect.
2020-08-24 17:09:33 +02:00
Nikita Popov
8c3574bd6c Remove php_my_setlocale workaround
This works around a macro-expansion issue that is no longer
relevant in PHP 8.
2020-08-24 16:50:03 +02:00
Christoph M. Becker
c925028d49 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #79986: str_ireplace bug with diacritics characters
2020-08-24 11:10:09 +02:00
Christoph M. Becker
5ab7b30cd6 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79986: str_ireplace bug with diacritics characters
2020-08-24 11:09:38 +02:00
Christoph M. Becker
844a2dd6ac Fix #79986: str_ireplace bug with diacritics characters
`tolower()` returns an `int`, so we must not convert to `char` which
may be `signed` and as such may be subject to overflow (actually,
implementation defined behavior).

Closes GH-6007
2020-08-24 11:08:48 +02:00
Nikita Popov
dd858460bb Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79951
2020-08-11 10:35:59 +02:00
Nikita Popov
66d9f4d985 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79951
2020-08-11 10:35:25 +02:00
Nikita Popov
9d9dffe60a Fixed bug #79951
One branch did not release tmp_replace_entry_str.

Also reduce the scope of some variables.
2020-08-11 10:33:59 +02:00
Nikita Popov
745bc4c2ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79849
2020-07-14 12:43:03 +02:00
Nikita Popov
162776a132 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79849
2020-07-14 12:42:46 +02:00
Evgeny Stepanischev
ce149b0cb8 Fixed bug #79849
Closes GH-5853.
2020-07-14 12:41:43 +02:00
Nikita Popov
12214e1d46 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79817
2020-07-10 14:07:59 +02:00
Nikita Popov
3f8d71d37f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79817
2020-07-10 14:07:17 +02:00
Nikita Popov
a72c53a070 Fixed bug #79817
Use *_IND macros in a few places in string.c.
2020-07-10 14:06:41 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Alex Dowad
7e2147be23 Clean up some unused code (and fix some comments) in build scripts
- Fix typo in build/php.m4

- Nothing uses HAVE_INTTYPES_H; so remove check for header file

- Nothing defines ZEND_ACCONFIG_H_NO_C_PROTOS; so remove #ifndef

- `format_money` was removed in 2019, so <monetary.h> no longer needed

- Nothing uses HAVE_NETDB_H; so remove check for header file

- Nothing checks HAVE_TERMIOS_H; so remove check for header file

    (This was actually added when Wez Furlong was adding the original implementation of
    PTY support in `proc_open`, since replaced.)

- Nothing checks HAVE_SYS_AUXV_H; so remove check for header file

- PHP_BUILD_DATE variable is not used for anything, so remove it

    This variable was added to the Makefile, but from there, was not used for anything.
    The comments suggest it was intended to allow 'reproducible builds'. Presumably,
    this means that if a bug is found in a PHP binary somewhere, one could look at the
    Makefile which it was built from, see the date, and then could check the same
    code version out from source control. But... there can easily be multiple commits
    to the repo in the same day. Also, what makes us think that the Makefile which a
    binary was built from will be easily available?

    Besides, ext/standard/info.c already embeds the build date and time in each binary...
    but it does it using `__DATE__` and `__TIME__` (see `php_print_info`).

- Nothing checks HAVE_FINITE; so don't check for function

- Grammar fix to comment in build/php.m4

- Nothing sets $php_ldflags_add_usr_lib variable in configure, so remove conditional

    This was added in 2002, when Rasmus was having difficulty building PHP on some
    host and needed to have /usr/lib in the rpath. It was never documented and
    probably has never been used by anyone else.
2020-06-19 22:04:52 +02:00
twosee
83a77015ad Add helper APIs for maybe-interned string creation
Add ZVAL_CHAR/RETVAL_CHAR/RETURN_CHAR as a shortcut for using
ZVAL_INTERNED_STRING and ZSTR_CHAR.

Add zend_string_init_fast() as a helper for the empty string /
one char interned string / zend_string_init() pattern.

Also add corresponding ZVAL_STRINGL_FAST etc macros.

Closes GH-5684.
2020-06-08 15:31:52 +02:00
twosee
88355dd338 Constify char * arguments of APIs
Closes GH-5676.
2020-06-08 10:38:45 +02:00
Christoph M. Becker
5a04796f76 Fix MSVC level 1 (severe) warnings
We fix (hopefully) all instances of:

* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4005>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4024>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4028>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4047>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4087>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4090>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4273>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4312>

`zend_llist_add_element()` and `zend_llist_prepend_element()` now
explicitly expect a *const* pointer.

We use the macro `ZEND_VOIDP()` instead of a `(void*)` cast to suppress
C4090; this should prevent accidential removal of the cast by
clarifying the intention, and makes it easier to remove the casts if
the issue[1] will be resolved sometime.

[1] <https://developercommunity.visualstudio.com/content/problem/390711/c-compiler-incorrect-propagation-of-const-qualifie.html>
2020-06-05 11:17:05 +02:00
Nikita Popov
2414b3d775 Ensure ctype_string is NULL for C locale
We already document that this is the case, but currently it's only
true if setlocale() has not been called. Make sure ctype_string is
always NULL, even with an explicit "C" locale call, so we can
more efficiently check whether we are in the "C" locale.

Closes GH-5542.
2020-05-07 21:26:13 +02:00
Nikita Popov
3f76947303 Rename locale_string to ctype_string
To make it more obvious that this only refers to the LC_CTYPE
locale.
2020-05-07 18:45:03 +02:00
Xinchen Hui
5d8cf36022 Folder marks 2020-05-07 23:03:25 +08:00
William Hudgins
31fb6a08b3 Add str_starts_with() and str_ends_with()
RFC: https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions

Closes GH-5300.
2020-05-05 16:03:47 +02:00
Xinchen Hui
f5fe4c3c38 Use ascii lowercase if locale is default C 2020-04-30 18:43:09 +08:00
Nikita Popov
90705d44e3 Treat invalid characters in basename() consistently
Always simply ignore (pass through) them. Previously the behavior
depended on where the invalid character occurred, as it messed
up the state management.
2020-04-29 18:43:09 +02:00
Nikita Popov
d50a12629d Clean up naming in basename() implementation 2020-04-29 18:43:09 +02:00
Nikita Popov
8e411fe54e Revert "Merge branch 'sse2_strtolower' of https://github.com/laruence/php-src"
This reverts commit 5a6373f904, reversing
changes made to 45cb42166d.

This breaks strtolower-win32.phpt.
2020-04-29 09:49:01 +02:00
Xinchen Hui
5a6373f904 Merge branch 'sse2_strtolower' of https://github.com/laruence/php-src
* 'sse2_strtolower' of https://github.com/laruence/php-src:
  Use ascii lowercase if locale is default C
2020-04-29 12:26:06 +08:00
Nikita Popov
dc1574e0a0 Fix ifunc resolver return type warning 2020-04-28 15:25:35 +02:00
Xinchen Hui
a233e128a5 Use ascii lowercase if locale is default C 2020-04-28 11:33:02 +08:00
Máté Kocsis
6111d64cda
Improve a last couple of argument error messages
Closes GH-5404
2020-04-20 13:09:00 +02:00
Máté Kocsis
1f48feebb9
Improve some TypeError and ValueError messages
Closes GH-5377
2020-04-14 14:38:45 +02:00
Máté Kocsis
bb6f374048
Improve argument error messages in ext/standard
Closes GH-5198
2020-03-18 19:56:10 +01:00
Philipp Tanlak
1668ad7cb1 Add str_contains() function
RFC: https://wiki.php.net/rfc/str_contains

Closes GH-5179.
2020-03-16 11:05:26 +01:00
Nikita Popov
e8678fcb42 Fixed bug #75902
Don't special-case nested arrays/objects in str_replace(), instead
perform a string cast on them as well. For arrays, this will always
result in the usual conversion warning.

This behavior is consistent with preg_replace(). If we didn't want
to cast the array to string here, we should instead perform the
replacement recursively. Silently copying it is just confusing.
2020-03-10 16:49:17 +01:00
Máté Kocsis
960318ed95
Change argument error message format
Closes GH-5211
2020-02-26 15:00:08 +01:00
Máté Kocsis
ac0853eb26
Make type error messages more consistent
Closes GH-5092
2020-02-17 14:22:17 +01:00
Nikita Popov
8dd91f52a5 Remove state pointer argument from php_strip_tags 2020-01-27 16:13:36 +01:00
Christoph M. Becker
5d65641011 Merge branch 'PHP-7.4'
* PHP-7.4:
  Yet another check for php_strip_tags_ex()
2020-01-24 13:04:26 +01:00
Christoph M. Becker
372b678e56 Yet another check for php_strip_tags_ex() 2020-01-24 13:02:02 +01:00
Christoph M. Becker
1b7343b93c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Yet another check for php_strip_tags_ex()
2020-01-24 12:51:02 +01:00
Christoph M. Becker
6d57476fd7 Yet another check for php_strip_tags_ex() 2020-01-24 12:50:24 +01:00
Stanislav Malyshev
a698e36aa8 Merge branch 'PHP-7.4'
* PHP-7.4:
  More checks for php_strip_tags_ex
2020-01-22 23:06:35 -08:00
Stanislav Malyshev
984d508825 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  More checks for php_strip_tags_ex
2020-01-22 23:06:28 -08:00
Stanislav Malyshev
dd3c664f8f Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  More checks for php_strip_tags_ex
2020-01-22 22:41:56 -08:00
Stanislav Malyshev
2dc170e25d More checks for php_strip_tags_ex 2020-01-22 22:37:30 -08:00
Stanislav Malyshev
545f77d313 Merge branch 'PHP-7.4'
* PHP-7.4:
  Update NEWS
  Fix bug #79037 (global buffer-overflow in `mbfl_filt_conv_big5_wchar`)
  Fix #79099: OOB read in php_strip_tags_ex
  Fix #79091: heap use-after-free in session_create_id()
2020-01-20 22:47:28 -08:00