Commit Graph

929 Commits

Author SHA1 Message Date
Graham Campbell
51fb8398e2 Add additional preg_match test case
(cherry picked from commit a1a044dcc7
on author's explicit request)
2020-04-23 17:35:09 +02:00
Nikita Popov
13bfa9f5ac Fixed bug #79188 2020-02-05 11:18:46 +01:00
Christoph M. Becker
e1da72bdf1 Fix #78853: preg_match() may return integer > 1
Commit 54ebebd[1] optimized the match loop, but for this case it has
been overlooked, that we must only loop if we're doing global matching.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=54ebebd686255c5f124af718c966edb392782d4a>
2019-11-22 19:26:26 +01:00
Nikita Popov
6dcc0b859f Fix php_pcre_mutex_free()
We should only set the mutex to NULL if we actually freed it.
Due to missing braces non-main threads may currently set it to
NULL first.
2019-11-07 14:31:19 +01:00
Nikita Popov
736af5f660 Merge branch 'PHP-7.2' into PHP-7.3 2019-10-08 16:13:17 +02:00
Sergei Turchanov
a8f60ac9dd Add pcre_get_compiled_regex_cache_ex() with local_aware flag
A new function `pcre_get_compiled_regex_cache_ex()` is introduced,
which allows to compile regexp pattern using the "C" locale instead
of a current locale.

This will be needed to replace setlocale() usage in fileinfo,
which is not thread-safe.
2019-10-08 16:11:55 +02:00
Nikita Popov
ab61d5caf9 Backport fix for uaf during pcre jit fallback
Backports parts of https://vcs.pcre.org/pcre2?view=revision&revision=1175
fixing https://bugs.exim.org/show_bug.cgi?id=2453.
2019-10-07 13:23:56 +02:00
Nikita Popov
1d6e9da743 Improve diagnostic on PCRE JIT mmap failure
Print a more informative message that indicates that this is
likely a permission issue, and also indicate that pcre.jit=0
can be used to work around it.

Also automatically disable the JIT, so that this message is
only shown once.

See bug #78630.
2019-10-04 16:03:38 +02:00
Nikita Popov
85b001974a Remove unstable test output
This may be printed in a different order, and we don't care about
it anyway.
2019-09-18 16:36:29 +02:00
Nikita Popov
e11ed02870 Fixed bug #78272
Use MAP_JIT only when running under hardened runtime, because MAP_JIT
is incompatible with fork().

The check is based on
f879e35e3e.
2019-09-18 10:41:27 +02:00
Nikita Popov
03efeda538 Backport MAP_JIT fixes from PCRE2 10.33
This is intended to fix the primary issue from bug #77260.

Prior to macOS 10.14 multiple MAP_JIT segments were not permitted,
leading to mmap failures and corresponding "no more memory" errors
on macOS 10.13.
2019-09-18 09:28:54 +02:00
Stanislav Malyshev
d1646e328a Fix test
Not sure why offset changed... probably different PCRE version calculates
them in different way.
2019-08-25 20:06:02 -07:00
Stanislav Malyshev
5d25ebb0dd Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #75457: heap-use-after-free in php7.0.25
2019-08-25 19:21:04 -07:00
Stanislav Malyshev
4b4a656d9e Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix #75457: heap-use-after-free in php7.0.25
2019-08-25 19:20:59 -07:00
Christoph M. Becker
7bf1f9d561 Fix #75457: heap-use-after-free in php7.0.25
Backport <https://vcs.pcre.org/pcre?view=revision&revision=1638>.
2019-08-25 19:19:50 -07:00
Remi Collet
08aafbe93e ensure proper settings for test 2019-08-20 16:30:52 +02:00
Christoph M. Becker
b419b24ead Remove upgrade-pcre.php script
This script has not been updated for PCRE2, and it's mostly useless
anyway.  Therefore we remove it altogether.
2019-08-01 10:49:05 +02:00
Christoph M. Becker
8947fd9e9f Fix #78338: Array cross-border reading in PCRE
We backport r1092 from pcre2.
2019-07-29 14:49:33 -07:00
Peter Kokot
624488b5e8 Fix bug #78197: PCRE2 version check
When external PCRE library version is of format ##.##-RC# the check
failed.
2019-07-01 02:42:29 +02:00
Nikita Popov
11b354dd54 Merge branch 'PHP-7.2' into PHP-7.3 2019-06-17 13:30:56 +02:00
Nikita Popov
03db04c3ab Accept null for preg_quote delimiter argument
Related to bug #78163.
2019-06-17 13:30:15 +02:00
Christoph M. Becker
d8b7728b0e Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77827: preg_match does not ignore \r in regex flags
2019-03-31 13:33:21 +02:00
Christoph M. Becker
88460c017a Fix #77827: preg_match does not ignore \r in regex flags 2019-03-31 13:31:54 +02:00
Remi Collet
e68fd40e22 ensure pcre.jit=1 for this test 2019-03-22 15:31:36 +01:00
Remi Collet
bb47fb0783 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  ensure pcre.jit=1 for these tests
2019-03-22 15:01:49 +01:00
Remi Collet
2e9dccef78 ensure pcre.jit=1 for these tests 2019-03-22 15:00:31 +01:00
Remi Collet
c421d9afec fix test for upcoming pcre2 10.33
"group name ..." => "subpattern name ..."
2019-03-19 16:15:14 +01:00
Nikita Popov
661bce47ae Fixed bug #76127
Per documentation, and consistent with other preg functions, we
should return false if an error occurred.
2019-03-19 13:57:39 +01:00
Nikita Popov
b1deb98c42 Fixed bug #77338
Set preg_options to 0 in php_pcre_get_compiled_regex(_ex). These
options are intended to be passed to pcre2_match. However, we do
not have any flags that actually need to be set during matching
(all relevant flags are set during compilation), and the preg_flags
value is used for PHP-specific flags instead.

This parameter should be removed entirely in master to avoid confusion.
2018-12-26 17:11:27 +01:00
Anatol Belski
ef1269d5c1 Fixed bug #77193 Infinite loop in preg_replace_callback
Don't return preallocated match data more than once in nested calls.
2018-12-01 10:24:06 +01:00
Anatol Belski
68ad401b34 Implement handling for JIT recognition when cross compiling 2018-11-05 01:15:09 +01:00
Anatol Belski
aea411657e Change the way JIT availability is checked
The pcre2_jit_compile_8 sysmbol is always available, even JIT might be
not. If JIT is not enabled explicitly and is enabled in the PHP runtime,
this will lead to a malfunction. This approach ensures JIT is indeed
available on the given platform. For cross compilation this might get
complicated, as it would require an explicit processor architecture and
PCRE2 version check.

Another solution for this case is to run pcre2_config at runtime. That
however would require more condition checks that would impact
architectures where JIT is available.
2018-11-03 20:50:05 +01:00
Peter Kokot
b746e69887 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:32:30 +02:00
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:31:31 +02:00
Peter Kokot
113213f027 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:29:24 +02:00
Peter Kokot
782352c54a Trim trailing whitespace in *.phpt 2018-10-14 19:45:12 +02:00
Peter Kokot
17ccbeec32 Trim trailing whitespace in *.phpt 2018-10-14 19:44:14 +02:00
Peter Kokot
7af945e271 Trim trailing whitespace in *.phpt 2018-10-14 19:43:12 +02:00
Peter Kokot
1c850bfcca Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:55:24 +02:00
Peter Kokot
60a69daec6 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:54:08 +02:00
Peter Kokot
03f3b8479b Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:51:01 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Peter Kokot
7f6387b59a Trim trailing whitespace in source code files 2018-10-13 14:12:55 +02:00
Peter Kokot
85290bbfcc Convert CRLF line endings to LF
This patch simplifies line endings tracked in the Git repository and
syncs them to all include the LF style instead of the CRLF files.

Newline characters:
- LF (\n) (*nix and Mac)
- CRLF (\r\n) (Windows)
- CR (\r) (old Mac, obsolete)

To see which line endings are in the index and in the working copy the
following command can be used:
`git ls-files --eol`

Git additionally provides `.gitattributes` file to specify if some files
need to have specific line endings on all platforms (either CRLF or LF).

Changed files shouldn't cause issues on modern Windows platforms because
also Git can do output conversion is core.autocrlf=true is set on
Windows and use CRLF newlines in all files in the working tree.

Unless CRLF files are tracked specifically, Git by default tracks all
files in the index using LF newlines.
2018-10-13 11:23:20 +02:00
Peter Kokot
2aa897476f Convert CRLF line endings to LF
This patch simplifies line endings tracked in the Git repository and
syncs them to all include the LF style instead of the CRLF files.

Newline characters:
- LF (\n) (*nix and Mac)
- CRLF (\r\n) (Windows)
- CR (\r) (old Mac, obsolete)

To see which line endings are in the index and in the working copy the
following command can be used:
`git ls-files --eol`

Git additionally provides `.gitattributes` file to specify if some files
need to have specific line endings on all platforms (either CRLF or LF).

Changed files shouldn't cause issues on modern Windows platforms because
also Git can do output conversion is core.autocrlf=true is set on
Windows and use CRLF newlines in all files in the working tree.

Unless CRLF files are tracked specifically, Git by default tracks all
files in the index using LF newlines.
2018-10-13 11:22:30 +02:00
Peter Kokot
3f72c77ce4 Convert CRLF line endings to LF
This patch simplifies line endings tracked in the Git repository and
syncs them to all include the LF style instead of the CRLF files.

Newline characters:
- LF (\n) (*nix and Mac)
- CRLF (\r\n) (Windows)
- CR (\r) (old Mac, obsolete)

To see which line endings are in the index and in the working copy the
following command can be used:
`git ls-files --eol`

Git additionally provides `.gitattributes` file to specify if some files
need to have specific line endings on all platforms (either CRLF or LF).

Changed files shouldn't cause issues on modern Windows platforms because
also Git can do output conversion is core.autocrlf=true is set on
Windows and use CRLF newlines in all files in the working tree.

Unless CRLF files are tracked specifically, Git by default tracks all
files in the index using LF newlines.
2018-10-13 11:21:27 +02:00
Remi Collet
bbfea4b470 Allow to disable pcre.jit when system library is used
as it is for now broken on some arch (s390x...)
2018-10-04 11:45:35 +02:00
Anatol Belski
9f3aac9e39 Fix test and add skip section 2018-09-22 02:10:43 +02:00
Anatol Belski
9c58ab37c7 Add test for bug #76909 2018-09-21 15:57:00 +02:00
Anatol Belski
7a02ecb7fe Fixed bug #76909 preg_match difference between 7.3 and < 7.3
Applied upstream patch, see https://bugs.exim.org/show_bug.cgi?id=2321
2018-09-21 15:55:03 +02:00