Commit Graph

1237 Commits

Author SHA1 Message Date
Nikita Popov
89b4a46d56 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix default sendmail path when not found during build
2020-05-11 10:46:07 +02:00
Nikita Popov
d050d74477 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix default sendmail path when not found during build
2020-05-11 10:46:00 +02:00
Indrek Ardel
517431892b Fix default sendmail path when not found during build
Closes GH-5548.
2020-05-11 10:45:23 +02:00
Máté Kocsis
4a816584a4
Make float to string casts locale-independent
From now on, float to string casting will always behave locale-independently.
RFC: https://wiki.php.net/rfc/locale_independent_float_to_string
Closes GH-5224

Co-authored-by: George Peter Banyard <girgias@php.net>
2020-05-08 10:52:23 +02:00
Nikita Popov
c50cfc4d3d Add quiet parameter to internal HTML entities API
In some places, we need to make sure that no warnings are thrown
due to unknown encoding. The error reporting code tried to avoid
this by determining a "safe charset", but this introduces subtle
discrepancies in which charset is picked (normally
internal_encoding takes precedence). Avoid this by suppressing
the warning in the first place.

While here, use the fallback logic to print error messages with
substitution characters more consistently, to avoid skipping
parts of the error message entirely.
2020-05-07 15:46:08 +02:00
Nikita Popov
c4ad8beaa8 Do not inherit LC_CTYPE locale from environment
Treatment of locales in PHP is currently inconsistent: The LC_ALL
locale is set to "C", as is standard behavior on program startup.
The LC_CTYPE locale is set to "", which will inherit it from the
environment. However, the inherited LC_CTYPE locale will only be
used in some cases, while in other cases it is necessary to perform
an explicit setlocale() call in PHP first. This is the case for
the locale-sensitive handling in the PCRE extension.

Make things consistent by *never* inheriting any locales from the
environment. LC_ALL, including LC_CTYPE will be "C" on startup.
A locale can be set or inherited through an explicit setlocale()
call, at which point the behavior will be fully consistent and
predictable.

Closes GH-5488.
2020-04-30 10:22:51 +02:00
Nikita Popov
78d3af4529 Make sure php_get_internal_encoding() returns non-empty
Even if default_charset is set to "", we should still return
"UTF-8" as the default value here. Setting default_charset to ""
suppresses the header emission, but shouldn't change anything
about our encoding defaults.
2020-03-31 11:06:15 +02:00
Nikita Popov
018251a7c4 Fixed bug #71876
This is a backport of fcdc0a6db0
to the PHP-7.3 branch. We need to make sure that OnUpdateString
is also called for a NULL value, otherwise the reset of the encoding
at the end of the request will not work.

I believe I already tried to land this before once, but it didn't
actually end up on the PHP-7.3 branch due to a push conflict that
I only noticed just now.
2020-01-17 09:47:31 +01:00
Máté Kocsis
e1b57310b1
Use RETURN_THROWS() during ZPP in main, sapi, win32, and Zend 2019-12-30 17:38:10 +01:00
Nikita Popov
83ff4f5986 Merge branch 'PHP-7.4'
* PHP-7.4:
  Free buffer in php_verror even if it is empty
2019-12-17 16:47:49 +01:00
Nikita Popov
e45b613950 Free buffer in php_verror even if it is empty
vspprintf allocates a buffer even if the resulting string is empty.
2019-12-17 16:46:52 +01:00
Nikita Popov
ed55a61b8b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix resetting of internal_encoding and friends
2019-12-17 16:28:56 +01:00
Nikita Popov
fcdc0a6db0 Fix resetting of internal_encoding and friends
We need to update the value even if new_value is NULL. In particular,
it should be reset back to NULL after each request if the setting was
not specified on startup. Otherwise we leave dangling pointers.
2019-12-17 16:27:56 +01:00
Nikita Popov
db233501ff Use clean shutdown on uncaught exception 2019-10-11 12:41:15 +02:00
Christoph M. Becker
508a179568 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78656: Parse errors classified as highest log-level
2019-10-09 17:30:37 +02:00
Christoph M. Becker
973617cacd Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78656: Parse errors classified as highest log-level
2019-10-09 17:29:54 +02:00
Christoph M. Becker
bbd481c11d Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #78656: Parse errors classified as highest log-level
2019-10-09 17:28:50 +02:00
Erik Lundin
3164186d53 Fix #78656: Parse errors classified as highest log-level 2019-10-09 17:27:32 +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
790ed7d540 Enable display_startup_errors by default 2019-09-06 14:33:03 +02:00
Benjamin Eberlei
58d661cd7d Cleanup unnecessary if guard clause to free buffer. 2019-08-18 12:28:40 +02:00
Nikita Popov
2e4f76dc80 Merge branch 'PHP-7.4' 2019-08-13 10:23:32 +02:00
Nikita Popov
b01824e596 Fixed bug #78406 2019-08-13 10:22:32 +02:00
Nikita Popov
9a3aef3c21 Merge branch 'PHP-7.4' 2019-07-29 17:15:35 +02:00
Nikita Popov
6df1665bb3 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-29 17:14:40 +02:00
Nikita Popov
bbed5564eb Merge branch 'PHP-7.2' into PHP-7.3 2019-07-29 16:57:57 +02:00
Nikita Popov
38f1288b64 Fix Zend signals unblocking
There are a few parts here:
 * opcache should not be blocking signals while invoking compile_file,
   otherwise signals may remain blocked on a compile error. While at
   it, also protect SHM memory during compile_file.
 * We should deactivate Zend signals at the end of the request, to make
   sure that we gracefully recover from a missing unblock and signals
   don't remain blocked forever.
 * We don't use a critical section in deactivation, because it should
   not be necessary. Additionally we want to clean up the signal queue,
   if it is non-empty.
 * Enable SIGG(check) in debug builds so we notice issues in the future.
2019-07-29 15:17:32 +02:00
Nikita Popov
36db71df47 Merge branch 'PHP-7.4' 2019-07-22 12:28:40 +02:00
Nikita Popov
b3f74b0b7d Deprecate allow_url_include 2019-07-22 11:39:52 +02:00
Nikita Popov
3c2f433b2b Merge branch 'PHP-7.4' 2019-07-17 12:02:30 +02:00
Nikita Popov
856c5d2837 Revert "Avoid unused fstat() call"
This reverts commit 5a90dc77b8.

Let's try to go with the reverse direction here and actually trust
the reported size...
2019-07-17 11:49:10 +02:00
Nikita Popov
995b391621 Merge branch 'PHP-7.4' 2019-07-17 11:22:41 +02:00
Nikita Popov
5a90dc77b8 Avoid unused fstat() call
If we're including a file via PHP streams, we're not going to trust
the reported file size anyway and populate in a loop -- so don't
bother determining the file size in the first place. Only do this
for non-tty HANDLE_FP now, which is the only case where this
information was used.
2019-07-17 11:22:31 +02:00
Nikita Popov
b32e9a9227 Merge branch 'PHP-7.4' 2019-07-17 10:41:34 +02:00
Nikita Popov
a986e70991 Avoid double buffering in Zend streams
Disable buffering in PHP streams, to avoid storing and copying the
file contents twice.

This will call stream_set_option() on custom stream wrapper as
well, so the method needs to be implemented to avoid a warning.
2019-07-17 10:40:04 +02:00
Nikita Popov
c4a6998c62 Merge branch 'PHP-7.4' 2019-07-16 17:45:03 +02:00
Nikita Popov
b317f0eb59 Remove ZEND_HANDLE_MAPPED
The buf/len members are now simply used in addition to the main
stream, without changing the handle kind.
2019-07-16 17:44:32 +02:00
Nikita Popov
e0eca26285 Drop free_filename field from zend_file_handle
free_filename was always zero.
2019-07-16 17:07:26 +02:00
Nikita Popov
3faa903d47 Merge branch 'PHP-7.4' 2019-07-16 16:44:46 +02:00
Nikita Popov
49bac9b77b Introduce zend_stream_init_filename()
Avoid more ad-hoc initialization of zend_file_handle structures.
2019-07-16 16:44:37 +02:00
Nikita Popov
06cf349dc3 Merge branch 'PHP-7.4' 2019-07-16 15:48:24 +02:00
Nikita Popov
5161cebe28 Fix bug #52752 by not using mmap() to lex files
Using mmap() is unsafe under concurrent modification. If the file
is truncated, access past the end of the file may occur, which will
generate a SIGBUS error. Even if the length does not change, the
contents may, which is a situation that the lexer certainly is not
prepared to deal with either.

Reproduce with test.php:

    <?php
    file_put_contents(__DIR__ . '/test.tpl',
        'AAA<?php $string = "' .
        str_repeat('A', mt_rand(1, 256 * 1024)) .
        '"; ?>BBB' . "\r\n");
    require_once __DIR__ . '/test.tpl';

And:

    for ((n=0;n<100;n++)); do sapi/cli/php test.php & done
2019-07-16 15:47:10 +02:00
Peter Kokot
ccac19ed6c Merge branch 'PHP-7.4'
* PHP-7.4:
  Small typo and proto name fix
2019-07-15 18:15:58 +02:00
George Peter Banyard
548d1ec27c Small typo and proto name fix
Closes GH-4415
2019-07-15 18:15:17 +02:00
Nikita Popov
9207aef60c Merge branch 'PHP-7.4' 2019-07-15 16:26:25 +02:00
Nikita Popov
c5f1b384b5 Move shebang handling into the lexer
Instead of handling shebang lines by adjusting the file pointer in
individual SAPIs, move the handling into the lexer, where this is
both a lot simpler and more robust. Whether the shebang should be
skipped is controlled by CG(skip_shebang) -- we might want to do
that in more cases.

This fixed bugs #60677 and #78066.
2019-07-15 16:25:49 +02:00
Peter Kokot
e0ea444dd3 Merge branch 'PHP-7.4'
* PHP-7.4:
  Convert all php_error_docref0 to php_error_docref
2019-07-13 02:10:17 +02:00
George Peter Banyard
1c1de0c41a Convert all php_error_docref0 to php_error_docref
Closes GH-4394
2019-07-13 02:05:17 +02:00
Nikita Popov
05ac4acc24 Merge branch 'PHP-7.4' 2019-07-02 10:17:25 +02:00
Nikita Popov
b88ef3dc58 Remove unused (module|request)_shutdown_for_exec 2019-07-02 10:10:51 +02:00