Commit graph

169 commits

Author SHA1 Message Date
Niels Dossche
06d87e4c14 Fix GH-11629: bug77020.phpt tries to send mail
Closes GH-11636.
2023-07-10 13:29:49 +02:00
Christoph M. Becker
71c22efae7
Fix GH-9309: Segfault when connection is used after imap_close()
We actually need to check whether `php_imap_object.imap_stream` is
`NULL` to detect that the connection has already been closed.

Closes GH-9313.
2022-08-12 16:24:30 +02:00
Máté Kocsis
663536d7d9
Improve class inheritance error messages (#7307) 2021-07-27 09:42:37 +02:00
Nikita Popov
2bc23cc6e3 Deprecate imap NIL constant
Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 16:48:16 +02:00
Nikita Popov
b5a14e6c04 Port skipif.inc files to EXTENSIONS 2021-06-11 16:27:50 +02:00
Nikita Popov
39131219e8
Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov
7485978339
Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
George Peter Banyard
b6958bb847
Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
George Peter Banyard
27d40da95d Convert IMAPConnection to IMAP\Connection 2021-05-05 14:22:43 +01:00
Stanislav Malyshev
3d2c810eeb
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80710: imap_mail_compose() header injection
2021-04-26 22:26:42 -07:00
Stanislav Malyshev
a4d9ccbcd6
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80710: imap_mail_compose() header injection
2021-04-26 21:49:38 -07:00
Stanislav Malyshev
568df31698
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80710: imap_mail_compose() header injection
2021-04-26 21:48:16 -07:00
Christoph M. Becker
37962c61d2
Fix #80710: imap_mail_compose() header injection
Like `mail()` and `mb_send_mail()`, `imap_mail_compose()` must prevent
header injection.  For maximum backward compatibility, we still allow
header folding for general headers, and still accept trailing line
breaks for address lists.
2021-04-26 21:43:03 -07:00
George Peter Banyard
bfd3fda0f4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80800 imap_open() fails when the flags parameter includes CL_EXPUNGE
2021-02-27 13:14:23 +00:00
George Peter Banyard
1ee6aad248 Fix Bug #80800 imap_open() fails when the flags parameter includes CL_EXPUNGE
This also affected imap_reopen().
Add a supplementary test that the CL_EXPUNGE flag does have
the intended effect.

Closes GH-6732
2021-02-27 13:12:22 +00:00
Nikita Popov
b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

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

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Ayesh Karunaratne
af68d4aae6 IMAP: Declare IMAPConnection class as final (stub+test)
Updates the `IMAPConnection` class stub to make sure it has the `final` flag, and adds a test to verify it.
2020-12-23 21:21:32 +01:00
Ayesh Karunaratne
7f1659afcb IMAP: Disallow direct new IMAPConnection() construct
Disallows constructing an `IMAPConnection` class directly with `new IMAPConnection` construct, by throwing an `Error` exception if attempted.
`imap_open` is still the only way to create `IMAPConnection` objects.
2020-12-23 21:21:32 +01:00
George Peter Banyard
c6a8f201b1 EXPECTF imap_errors() test's authentication error 2020-12-22 23:14:11 +01:00
George Peter Banyard
7606994356 Make imap_errors() test no hang
Instead of attempting to connect with an invalid password, connect as an anonymous user.
As this is disabled in our Dovecot configuration, this generates an error, and fails fast.
2020-12-22 19:55:30 +01:00
George Peter Banyard
a80a029896 Optimize Dovecot configuration for IMAP tests
Closes GH-6531
2020-12-22 19:55:30 +01:00
George Peter Banyard
383779e502 Convert IMAP resource to object
Closes GH-6418
2020-12-22 03:06:35 +01:00
George Peter Banyard
426fe2f20c Standardize behaviour for int message number between functions 2020-12-03 17:43:08 +00:00
George Peter Banyard
e45cc31c41 Add tests for passing a UID instead of a message number 2020-12-03 16:38:22 +00:00
George Peter Banyard
5aaffc8095 Backport IMAP test modernization to PHP-8.0 branch
Closes GH-6476
2020-12-01 16:38:08 +00:00
Dmitry Stogov
4959c60524 Fixed incorrect "skipif.inc" include 2020-12-01 11:34:09 +03:00
George Peter Banyard
0076b47326 Fix Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
Checking for a valid Unique ID (UID) cannot use the convenience macro as they might
be larger than the message number which has for maximum value the total number of
current messages available in the mailbox.
2020-11-30 14:08:31 +00:00
George Peter Banyard
158d308197 Throw Value/TypeError for invalid $bodies in imap_mail_compose()
Small drive by refactoring to use HashTables

Closes GH-6371
2020-10-23 20:47:35 +01:00
George Peter Banyard
8b265fb602 Fix segfaults after conversion from zval to zend_string params 2020-10-22 15:50:01 +01:00
Christoph M. Becker
edd8bd64ba Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80242: imap_mail_compose() segfaults for multipart with rfc822
2020-10-20 19:02:15 +02:00
Christoph M. Becker
4ef7be20ab Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80242: imap_mail_compose() segfaults for multipart with rfc822
2020-10-20 19:00:16 +02:00
Christoph M. Becker
315b95b065 Fix #80242: imap_mail_compose() segfaults for multipart with rfc822
libc-client expects `TYPEMESSAGE` with an explicit subtype of `RFC822`
to have a `nested.msg` (otherwise there will be a segfault during
free), but not to have any `contents.text.data` (this will leak
otherwise).

Closes GH-6345.
2020-10-20 18:58:45 +02:00
Christoph M. Becker
486c49dee8 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Properly fix #80220
2020-10-20 13:36:41 +02:00
Christoph M. Becker
9cfd650697 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Properly fix #80220
2020-10-20 13:35:06 +02:00
Christoph M. Becker
7f3bdda29b Properly fix #80220
The original fix for that bug[1] broke the formerly working composition
of message/rfc822 messages, which results in a segfault when freeing
the message body now.  While `imap_mail_compose()` does not really
support composition of meaningful message/rfc822 messages (although
libc-client appears to support that), some code may still use this to
compose partial messages, and using string manipulation to create the
final message.

The point is that libc-client expects `TYPEMESSAGE` with an explicit
subtype of `RFC822` to have a `nested.msg` (otherwise there will be a
segfault during free), but not to have any `contents.text.data` (this
will leak otherwise).

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

Closes GH-6343.
2020-10-20 13:32:53 +02:00
Christoph M. Becker
b7c1834c6a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80239: imap_rfc822_write_address() leaks memory
2020-10-15 12:57:35 +02:00
Christoph M. Becker
7899ac4c14 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80239: imap_rfc822_write_address() leaks memory
2020-10-15 12:56:02 +02:00
Christoph M. Becker
5941b30bb8 Fix #80239: imap_rfc822_write_address() leaks memory
We have to free the address when we're finished with it.
2020-10-15 12:54:53 +02:00
Christoph M. Becker
5aec24c477 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #64076: imap_sort() does not return FALSE on failure
2020-10-13 19:41:27 +02:00
Christoph M. Becker
d9058b61fb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #64076: imap_sort() does not return FALSE on failure
2020-10-13 19:38:31 +02:00
Christoph M. Becker
db8bf0a9e0 Fix #64076: imap_sort() does not return FALSE on failure
If unsupported `$search_criteria` are passed to `imap_sort()`, the
function returns an empty array, but there is also an error on the
libc-client error stack ("Unknown search criterion: UNSUPPORTED
(errflg=2)").  If, on the other hand, unsupported `$criteria` or
unsupported `$flags` are passed, the function returns `false`.  We
solve this inconsistency by returning `false` for unsupported
`$search_criteria` as well.

Closes GH-6332.
2020-10-13 19:37:05 +02:00
Christoph M. Becker
818eb8f611 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80226: imap_sort() leaks sortpgm memory
2020-10-12 23:21:56 +02:00
Christoph M. Becker
12fc8f66e7 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80226: imap_sort() leaks sortpgm memory
2020-10-12 23:17:57 +02:00
Christoph M. Becker
8488c34fc6 Fix #80226: imap_sort() leaks sortpgm memory
We need to free what we have allocated.

Closes GH-6327.
2020-10-12 23:16:31 +02:00
Christoph M. Becker
11c752a5f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80216: imap_mail_compose() does not validate types/encodings
2020-10-12 16:30:48 +02:00
Christoph M. Becker
216d6a024a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80216: imap_mail_compose() does not validate types/encodings
2020-10-12 16:28:52 +02:00
Christoph M. Becker
73e43b6e19 Fix #80216: imap_mail_compose() does not validate types/encodings
We need to check whether the given `type`s and `encoding`s are within
bounds to avoid segfaults and out-of-bound reads.

Closes GH-6323.
2020-10-12 16:27:49 +02:00
Christoph M. Becker
0443c824a3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
2020-10-12 15:10:38 +02:00
Christoph M. Becker
4a469c7e98 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
2020-10-12 15:09:30 +02:00
Christoph M. Becker
c1962e900a Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
We have to clean up even on failure.

Closes GH-6322.
2020-10-12 15:08:30 +02:00