Commit graph

505 commits

Author SHA1 Message Date
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
Nikita Popov
422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a
conversion was necessary. This distinction no longer makes sense
since PHP 7.

The only difference that was still left is that _ex checked whether
the type is the same first, but the usage of these macros did not
actually distinguish on whether such an inlined check is valuable
or not in a given context.

Also drop the unused convert_to_explicit_type macros.
2021-01-14 12:11:11 +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
383779e502 Convert IMAP resource to object
Closes GH-6418
2020-12-22 03:06:35 +01:00
George Peter Banyard
fec771db87 Merge branch 'PHP-8.0'
* PHP-8.0:
  Standardize behaviour for int message number between functions
  Add tests for passing a UID instead of a message number
2020-12-03 17:44:47 +00: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
Sara Golemon
1071d85764
Flesh out HashTable insertion APIs
Fills out the array/object-property insert helpers for zend_array, zend_object, and zend_reference.

This adds the following matrix of 18 APIs
add_next_index_T()
add_index_T()
add_assoc_T()
add_assoc_T_ex()
add_property_T()
add_property_T_ex()

Where T in array, object, reference

Converted internal callsites currently doing an explicit object wrap.
2020-12-01 18:36:21 +00:00
George Peter Banyard
e42bf726c0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
  Rename XmlParser to XMLParser for consistency with XMLWriter/XMLReader
2020-11-30 14:08:49 +00: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
77582ec13f Merge branch 'PHP-8.0'
* PHP-8.0:
  Throw Value/TypeError for invalid $bodies in imap_mail_compose()
2020-10-23 20:48:52 +01: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
77d14477db Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug 76618
2020-10-22 17:06:07 +01:00
George Peter Banyard
ba27866aec Fix bug 76618
Apply patch which was attached to the bug in July 2018
2020-10-22 17:05:29 +01:00
George Peter Banyard
35f1b0bfaa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix segfaults after conversion from zval to zend_string params
2020-10-22 15:50:42 +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
9e9505669f Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80242: imap_mail_compose() segfaults for multipart with rfc822
2020-10-20 19:02:32 +02: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
11a2419c35 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Add char* cast to avoid compiler warnings
2020-10-20 16:34:40 +02:00
Christoph M. Becker
8f6cade864 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add char* cast to avoid compiler warnings
2020-10-20 16:33:56 +02:00
Christoph M. Becker
a54f0f7680 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add char* cast to avoid compiler warnings
2020-10-20 16:31:25 +02:00
Christoph M. Becker
de58fb34c9 Add char* cast to avoid compiler warnings
In libc-client 2007f `data` is declared as `unsigned char *`; there may
be variants which declare it as `void *`, but in any case picky
compilers may warn about a pointer type mismatch in the conditional
(and error with `-W-error`), so we're adding a `char *` cast for good
measure.
2020-10-20 16:29:42 +02:00
Christoph M. Becker
b8ff94ad23 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Properly fix #80220
2020-10-20 13:37:07 +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
f5b2dedc09 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix broken fix for #80239
2020-10-15 13:21:27 +02:00
Christoph M. Becker
ecd51aa099 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix broken fix for #80239
2020-10-15 13:20:58 +02:00
Christoph M. Becker
bc214c8423 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix broken fix for #80239
2020-10-15 13:19:30 +02:00
Christoph M. Becker
4b9db65f68 Fix broken fix for #80239
No idea why that `git am` failed that badly.
2020-10-15 13:18:34 +02:00
Christoph M. Becker
42d6844358 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80239: imap_rfc822_write_address() leaks memory
2020-10-15 12:58:07 +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
6af54d864d Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #64076: imap_sort() does not return FALSE on failure
2020-10-13 19:41:54 +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
98a20acbaa Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Ignore memory leaks reported for some libc-client functions
2020-10-13 13:13:26 +02:00
Christoph M. Becker
ade146c9ed Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Ignore memory leaks reported for some libc-client functions
2020-10-13 13:12:39 +02:00
Christoph M. Becker
9c7b607320 Ignore memory leaks reported for some libc-client functions
At least on Windows, some static variables are lazily initialized
during `mail_open()` and `mail_lsub()`, which are reported as memory
leaks.  We suppress these false positives.

Closes GH-6326.
2020-10-13 13:09:29 +02:00
Christoph M. Becker
d523de69d7 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80226: imap_sort() leaks sortpgm memory
2020-10-12 23:22:19 +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
51cb9b8373 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Change parameters types from int to bool
2020-10-12 23:10:41 +02:00
Christoph M. Becker
8d4774a2df Change parameters types from int to bool
These are typical boolean parameters, so we shouldn't advertize them as
integers.  For the `$reverse` parameter that even fixes expectations,
because the `reverse` member is a bitfield of 1 bit, so assigning any
even integer would not set it.

Closes GH-6328.
2020-10-12 23:10:13 +02:00
Christoph M. Becker
8e4022b461 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80216: imap_mail_compose() does not validate types/encodings
2020-10-12 16:31:03 +02:00