Commit graph

549 commits

Author SHA1 Message Date
George Peter Banyard
6c25257db0 ext/imap: Refactor common conditional property assignment
By introducing new functions and doing some preprocessor black magic
2023-06-18 13:05:02 +01:00
George Peter Banyard
d714ae8964 ext/imap: Refactor imap_fetch_overview()
Reduce level of indentations by using early guards to return/continue
2023-06-18 13:05:02 +01:00
George Peter Banyard
b1f24e3bea ext/imap: Add const qualifier for header_injection()
Also reformat long if condition to make it clearer
2023-06-18 13:05:02 +01:00
George Peter Banyard
b1dd9b8a39 ext/imap: Do not condition on number of arguments but on pointer being set or not 2023-06-18 13:05:02 +01:00
George Peter Banyard
0b99bc21e5 ext/imap: Cleanup custom implementation of rfc822_write_address()
This is used only when c-client does not have this feature, maybe this is something we should asume nowadays?
2023-06-18 13:05:02 +01:00
George Peter Banyard
9798dc20e2 ext/imap: Use propery API instead of php_imap_hash_add_object()
It was only ever used to update an object property table and never an associative array.
2023-06-18 13:05:02 +01:00
George Peter Banyard
5d0304876f ext/imap: Remove php_imap_list_add_object() function
The symtable was always an array so use appropriate HashTable API
2023-06-18 13:05:02 +01:00
George Peter Banyard
85a4a80da3
ext/imap: Refactor + Update to modern property write API (#11415)
Use common functions for creating and setting up similar objects

The increase in verbosity compared to the ``add_property_*()`` version is somewhat unfortunate, but the behaviour of ``add_property_str()`` releasing the zend_string is suboptimal, confusing, and has me concerned.
2023-06-14 05:50:23 +01:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Ilija Tovilo
d98963a071
Switch to Ubuntu 22.04 for GitHub actions jobs
Closes GH-10814
2023-03-10 00:17:23 +01:00
Máté Kocsis
7936c8085e
Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385) 2023-01-23 10:52:14 +01:00
George Peter Banyard
4a365132e7
Merge branch 'PHP-8.2'
* PHP-8.2:
  Add a new imap_is_open() function to check that a connection object is still valid
2022-12-13 23:48:48 +00:00
George Peter Banyard
52a891aeaa
Add a new imap_is_open() function to check that a connection object is still valid 2022-12-13 23:48:03 +00:00
Christoph M. Becker
e4ef394c6b
Drop superfluous check for imap_stream
`GET_IMAP_STREAM` already checks whether `.imap_stream` is `NULL`, and
bails out in that case.

Closes GH-10053.
2022-12-06 11:01:18 +01:00
Christoph M. Becker
e885831670
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-9309: Segfault when connection is used after imap_close()
2022-08-12 16:25:46 +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
Tim Düsterhus
176a484df2 Mark parameter in ext/imap as sensitive 2022-06-13 11:09:12 +02:00
Máté Kocsis
e7d482d896
Declare ext/imap constants in stubs (#8715) 2022-06-06 13:08:32 +02:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Nikita Popov
2a4dba7b14 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix maybe-uninitialized warning
2021-08-17 12:27:39 +02:00
Nikita Popov
b66168e86b Fix maybe-uninitialized warning
Some GCC versions don't like zend_try in loop. Avoid the issue
by pulling it out of the loop, we don't particularly care about
skipping further warnings if a bailout occurs, just that it
does not interrupt shutdown.

Closes GH-7380.
2021-08-17 12:27:32 +02:00
Nikita Popov
f603934a5e Merge branch 'PHP-8.0'
* PHP-8.0:
  Prevent bailout during imap shutdown error reporting
2021-08-17 10:35:16 +02:00
Nikita Popov
85eafc31e8 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Prevent bailout during imap shutdown error reporting
2021-08-17 10:35:07 +02:00
Nikita Popov
bcc2f0705d Prevent bailout during imap shutdown error reporting
This is a non-intrusive, minimal fix for bug #81316, which prevents
a bailout during imap RSHUTDOWN and prevents the basic shutdown
handler from being skipped.

I wasn't able to make the issue reproduce in a small test.
2021-08-17 10:33:39 +02:00
Kamil Tekiela
cd0cd3d31e
Fix typos (#7327) 2021-08-01 18:03:30 +01:00
Joe Watkins
570d9b63e9
Not serializable flag permeation 2021-07-20 12:28:35 +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
Patrick Allaert
ceb6fa6dc0 Convert some recently introduced zend_bool to bool
As well as `scripts/dev/check_parameters.php` utility.

Cfr. 3e01f5afb1
2021-06-18 15:21:39 +01:00
Nikita Popov
bc8aa7d0e0 Use free_obj in IMAP\Connection
Looks like this incorrect pattern was copied from the FTP
implementation.
2021-06-09 12:14:41 +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
27d40da95d Convert IMAPConnection to IMAP\Connection 2021-05-05 14:22:43 +01:00
Nikita Popov
b74f5ee477 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build warning
2021-04-27 10:11:20 +02:00
Nikita Popov
7544f66da9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix build warning
2021-04-27 10:10:55 +02:00
Nikita Popov
310c0561a9 Fix build warning
This causes the build to fail on PHP-8.0 and higher.
2021-04-27 10:10:22 +02: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
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01: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
Máté Kocsis
98fb565c74
Generate class entries from stubs for another batch of extensions
Closes GH-6669
2021-02-08 19:53:55 +01:00
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