1
0
mirror of https://github.com/php/php-src.git synced 2026-04-30 03:33:17 +02:00
Commit Graph

1926 Commits

Author SHA1 Message Date
Alex Dowad 7bb5b435af mUTF-7 (UTF7-IMAP) conversion: handle illegal (non-RFC-compliant) input correctly
Instead of looking the other way and letting things slide, report errors when
the input does not follow the RFC.
2020-10-13 20:26:14 +02:00
Alex Dowad b43a7deacf Add 'mUTF-7' alias for UTF7-IMAP encoding 2020-10-13 20:26:14 +02:00
Alex Dowad b975817265 Add comment explaining mUTF-7 to mbfilter_utf7imap.c 2020-10-13 20:26:14 +02:00
Alex Dowad 648c1cb51e Add identify filter for UCS-2, UCS-2BE, and UCS-2LE encodings 2020-10-13 20:26:14 +02:00
Alex Dowad 374f31e364 Add mbstring identify filter for 'binary' encoding 2020-10-13 20:26:13 +02:00
Alex Dowad 97beecc251 Add identify filter for UTF-16, UTF-16LE, UTF-16BE
There was one faulty test in the suite which only passed before because UTF-16 had no
identify filter. After this was fixed, it exposed the problem with the test.
2020-10-13 20:26:13 +02:00
Nikita Popov 4371a4b241 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix incorrect zpp parameter count in mb_substr() / mb_strcut()
2020-10-13 17:47:11 +02:00
Nikita Popov 9b4094c3d7 Fix incorrect zpp parameter count in mb_substr() / mb_strcut()
These functions only accept 4 params.
2020-10-13 17:46:56 +02:00
Nikita Popov 40e920ebd9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix argument nullability in mbstring
2020-10-13 16:03:29 +02:00
Nikita Popov 124bce3c7a Fix argument nullability in mbstring
These arguments were declared nullable in stubs (and should be
nullable), but didn't accept null in zpp.
2020-10-13 16:03:04 +02:00
Alex Dowad a98838e3b6 Handle illegal bytes properly when converting to '7bit' encoding
Previously, mbstring would silently drop illegal bytes when converting a
string to '7bit' encoding.
2020-10-13 06:12:38 +02:00
Alex Dowad 4aa7430f68 Add mbstring identify filter for '7bit' encoding 2020-10-13 06:12:38 +02:00
Alex Dowad 0ffc1f55b3 Refactor mbfl_ident.c, mbfl_encoding.c, mbfl_memory_device.c, mbfl_string.c
- Make everything less gratuitously verbose
- Don't litter the code with lots of unneeded NULL checks (for things which
  will never be NULL)
- Don't return success/failure code from functions which can never fail
- For encoding structs, don't use pointers to pointers to pointers for the
  list of alias strings. Pointers to pointers (2 levels of indirection)
  is what actually makes sense. This gets rid of some extraneous
  dereference operations.
2020-10-13 06:12:38 +02:00
Alex Dowad e8b8ecbd4e Remove useless constants MBFL_CHP_{CTL,DIGIT,UALPHA,LALPHA,MSPECIAL} 2020-10-13 06:12:37 +02:00
Alex Dowad aabbee2318 Remove useless validity check when converting UTF-16LE -> wchar
The check ensures that the decoded codepoint is between 0x10000-0x10FFFF,
which is the valid range which can be encoded in a UTF-16 surrogate pair.
However, just looking at the code, it's obvious that this will be true.
First of all, 0x10000 is added to the decoded codepoint on the previous
line, so how could it be less than 0x10000?

Further, even if the 20 data bits already decoded were 0xFFFFF (all ones),
when you add 0x10000, it comes to 0x10FFFF, which is the very top of the
valid range. So how could the decoded codepoint be more than 0x10FFFF?
It can't.
2020-10-13 06:12:37 +02:00
Alex Dowad f474e5502c Refactor UTF-16LE -> wchar conversion code 2020-10-13 06:12:37 +02:00
Alex Dowad 3f1851dec2 Avoid compiler warnings related to mbstring flush functions 2020-10-13 06:12:37 +02:00
George Peter Banyard fd1672a7f3 Fix [-Wduplicated-cond] in MBString extension 2020-10-09 20:54:23 +01:00
Nikita Popov cafceea742 Update mbstring parameter names
Closes GH-6207.
2020-09-28 09:51:58 +02:00
Larry Garfield 94854e0dff Standardize mbstring and string on using 'string' as a parameter name.
Closes GH-6171.
2020-09-21 12:06:50 +02:00
Máté Kocsis e950ca13ea Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Nikita Popov c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Remi Collet b1c5532ad1 fix mbfl function prototypes
re-add mbfl_convert_filter_feed API
re-add pointer cast
2020-09-15 15:15:06 +02:00
Máté Kocsis c37a1cd650 Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
Máté Kocsis 1c81a34563 Make mb_send_mail() consistent with mail()
The $additional_headers parameter shouldn't accept null.
2020-09-14 11:52:33 +02:00
Máté Kocsis c98d47696f Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Nikita Popov f33fd9b7fe Throw ValueError on null bytes in mb_send_mail()
Instead of silently replacing with spaces.
2020-09-11 10:46:59 +02:00
George Peter Banyard 0444158529 Promote some warnings in MBString Regexes
Closes GH-5341
2020-09-09 14:55:07 +02:00
Alex Dowad 5b78d76ec8 mb_str_split is already documented on php.net
So remove TODO comment which implies that it's not.
2020-09-08 20:09:45 +02:00
Nikita Popov 2386f655d8 Always use PCRE for mbstring.http_output_conv_mimetypes
Instead of using either oniguruma or pcre depending on which is
available. We always have PCRE, so use it. This ensures consistent
behavior.
2020-09-08 15:02:15 +02:00
Nikita Popov 623bf96e7e Throw on invalid mb_http_input() type 2020-09-07 09:59:51 +02:00
Nikita Popov d57f9e5ea4 Handle null encoding in mb_http_input() 2020-09-04 17:15:35 +02:00
Alex Dowad a81061d36c Use symbolic constants in Japanese kana conversion code (not magic numbers)
Also correct misspelling of 'hiragana' as 'hirangana' at the same time.
2020-09-03 15:56:29 +02:00
Alex Dowad ec609916dc Remove unused 'from' field from mbfl_buffer_converter struct 2020-09-03 15:56:29 +02:00
Alex Dowad f699d65391 Add comment to mbfilter_tl_jisx0201_jisx0208.h
Explain the 'ZEN' and 'HAN' in symbolic constant names.
2020-09-03 15:56:29 +02:00
Alex Dowad a2b40ee9a5 Remove unneeded function mbfl_filt_ident_common_dtor
This was the default destructor for mbfl_identify_filter structs, but there's nothing
we actually need to do to those structs before freeing them.
2020-09-03 15:56:29 +02:00
Alex Dowad dcd6c6043e Remove unneeded function mbfl_filt_conv_common_dtor
This is a default destructor for mbfl_convert_filter structs. The thing is: there
isn't really anything that needs to be done to those structs before freeing them.
The default destructor just zeroed out some fields, but there's no reason why
we should actually do that.
2020-09-03 15:56:29 +02:00
Alex Dowad 409aa20ab0 Refactor mbfl_convert.c 2020-09-03 15:56:29 +02:00
Alex Dowad 73dcfb6faa Fix typos in mbstring tests
Man, I can be pedantic sometimes. Tiny little things like misspelled words just
hurt me inside. So while it's not really a big deal, I couldn't leave these typos
alone...
2020-09-02 20:48:22 +02:00
Máté Kocsis 3e800e997b Move custom type checks to ZPP
Closes GH-6034
2020-09-02 11:11:38 +02:00
Alex Dowad b03fd37677 Code cleanup in mbstring.c 2020-08-31 23:19:43 +02:00
Alex Dowad cdc664049c Comment constants in mbfl_consts.h, remove unused ones
These were unused, and almost certainly will never be used:

- MBFL_ENCTYPE_MWC4BE
- MBFL_ENCTYPE_MWC4LE
- MBFL_ENCTYPE_SHFTCODE
- MBFL_ENCTYPE_ENC_STRM

For the latter two, there were some encodings which were marked with these flags;
but nothing ever _checked_ these particular flags.
2020-08-31 23:18:56 +02:00
Alex Dowad 3a100cd7ac Add comment on mbstring East Asian Width table 2020-08-31 23:18:45 +02:00
Alex Dowad 7eddcabe2b Don't guard mbstring code with #ifdef HAVE_MBSTRING
This is just a very silly feature of mbstring -- you can compile the source files with
HAVE_MBSTRING undefined, and it will all just compile to (almost) nothing. What is the
use of this? Why compile the source files and link against them if you don't want the
mbstring extension? It doesn't make any kind of sense.
2020-08-31 23:18:13 +02:00
Alex Dowad 62317d592f Remove redundant includes from mbstring (and make sure correct config.h is used)
Very interesting... it turns out that when Valgrind support was enabled,
`#include "config.h"` from within mbstring was actually including the file "config.h"
from Valgrind, and not the one from mbstring!!

This is because -I/usr/include/valgrind was added to the compiler invocation _before_
-Iext/mbstring/libmbfl.

Make sure we actually include the file which was intended.
2020-08-31 23:17:58 +02:00
Alex Dowad b7808d02e8 Remove useless definition of NULL in mbfl_string.h
If NULL is not defined by the platform, mbfl_defs.h already defines it.
2020-08-31 23:17:49 +02:00
Alex Dowad ea3f0ee0b9 Optimize php_unicode_convert_case (cuts mbstring case conversion time ~15%)
This function uses various subfunctions to convert case of Unicode wchars.
Previously, these subfunctions would store the case-converted characters in
a buffer, and the parent function would then pass them (byte by byte) to
the next filter in the filter chain.

Rather than passing around that buffer, it's better for the subfunctions to
directly pass the case-converted bytes to the next filter in the filter chain.
This speeds things up nicely.
2020-08-31 23:17:25 +02:00
Alex Dowad ddc76e5abf Fix typos in comments in mb_send_mail 2020-08-31 23:17:14 +02:00
Alex Dowad a64241b540 Remove unused functions from mbstring
- mbfl_buffer_converter_reset
- mbfl_buffer_converter_strncat
- mbfl_buffer_converter_getbuffer
- mbfl_oddlen
- mbfl_filter_output_pipe_flush
- mbfl_memory_device_output2
- mbfl_memory_device_output4
- mbfl_is_support_encoding
- mbfl_buffer_converter_feed2
- _php_mb_regex_globals_dtor
- mime_header_encoder_feed
- mime_header_decoder_feed
- mbfl_convert_filter_feed
2020-08-31 23:16:57 +02:00
Alex Dowad 8d13348bb5 Separate implementation of mb_{en,de}code_numericentity
Rather than using a magic boolean parameter to choose different behavior of
the subfunction, inline it. The code size doesn't really grow anyways. And
soon these will be trimmed down more.
2020-08-31 23:16:28 +02:00