Commit graph

1286 commits

Author SHA1 Message Date
George Peter Banyard
501a72e354 Promote warning to value error in strpbrk()
Closes GH-4598
2019-11-22 00:36:54 +01:00
Nikita Popov
93ba3abe63 Warn on strtr(["" => "x"])
Previously:
 * If only ["" => "x"] was present, the original string was returned
   without warning.
 * If both ["" => "x"] and at least one more element was present,
   false was returned without warning.

New behavior:
 * Ignore "" keys in the replacement array (and perform any remaining
   replacement).
 * Throw a warning indicating that an empty string replacement has
   been ignored.

Closes GH-4792.
2019-10-30 10:53:45 +01:00
Colin O'Dell
e6d3146bdc Accept null lengths for substr functions()
If a null $length is passed to any of these functions, behave as if no
parameter was passed:

 - substr()
 - substr_count()
 - substr_compare()
 - iconv_substr()
2019-10-22 12:09:04 +02:00
Colin O'Dell
8ccd58baca Add Z_PARAM_LONG_OR_NULL macro 2019-10-22 12:09:04 +02:00
theodorejb
ef9736e062 Convert string function arginfo to PHP stubs 2019-10-07 11:13:16 +02:00
Nikita Popov
fdc133063d Convert count_chars invalid mode error to ValueError 2019-10-07 11:10:05 +02:00
Nikita Popov
647b1c7fcf Remove most uses of ZEND_PARSE_PARAMETERS_END_EX()
As ZPP now throws, it makes no sense to specify an explicit return
value.
2019-10-07 10:02:18 +02:00
Nikita Popov
c0a54f41b3 Merge branch 'PHP-7.4' 2019-09-30 15:06:51 +02:00
Nikita Popov
1f0ffece91 Merge branch 'PHP-7.3' into PHP-7.4 2019-09-30 15:06:43 +02:00
Nikita Popov
0805e132b0 Merge branch 'PHP-7.2' into PHP-7.3 2019-09-30 15:06:32 +02:00
Nikita Popov
6fcde56b03 Fixed bug #78612 2019-09-30 15:06:07 +02:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
George Peter Banyard
d0754b86b1 Promote warnings to errors in substr_count() 2019-08-31 23:37:04 +02:00
George Peter Banyard
0240b903c5 Promote warnings to errors in substr_compare() 2019-08-31 23:34:24 +02:00
George Peter Banyard
5b09e6043c Remove memory exhaustion checks in php_chunk_split() 2019-08-26 17:14:49 +02:00
George Peter Banyard
6d578482a9 Improve strpos and strstr function family implementation 2019-08-26 17:11:37 +02:00
George Peter Banyard
91f4e2e614 Promote warnings to errors in explode() 2019-08-26 11:35:03 +02:00
George Peter Banyard
743729d5bf Promote warnings to errors in str_pad() 2019-08-25 20:13:27 +02:00
Nikita Popov
6e3135070c Remove unnecessary haystack length check in stripos()
This falls out naturally from the following condition, because
either the needle length will be zero as well, or the needle
will be longer than the (empty) haystack.
2019-08-25 16:31:15 +02:00
Nikita Popov
4346d1b0e6 Remove unnecessary NULL check
needle_dup cannot be NULL here.
2019-08-25 16:30:16 +02:00
Nikita Popov
d955ee9f6b Make string size calculation in chunk_split more precise
The +1 on the string length is unnecessary, as we need the string
length without trailing NUL byte here.

The +1 on the chunks is only necessary if there is a rest. If the
string devides into chunks exactly, we don't need an extra chunk.

This makes the allocations exactly as large as it needs to be.
2019-08-25 15:34:37 +02:00
George Peter Banyard
9d18f23c4c Remove 'bogus' error condition in str_pad() 2019-08-24 16:05:00 +02:00
George Peter Banyard
1059e3dc39 Promote warnings to errors in str_repeat() 2019-08-23 20:01:19 +02:00
George Peter Banyard
f51421c629 Promote warnings to errors in chunk_split() 2019-08-22 21:45:36 +02:00
George Peter Banyard
fdff6cfd50 Promote warnings to errors in str_word_count() 2019-08-22 21:45:07 +02:00
George Peter Banyard
754d9f3da4 Promote warnings to errors in wordwrap() 2019-08-22 21:44:34 +02:00
George Peter Banyard
fe44e1637a Promote warnings to errors in dirname() 2019-08-22 21:44:01 +02:00
George Peter Banyard
698491d98a Promote warnings to errors in str_split() 2019-08-22 19:33:37 +02:00
George Peter Banyard
c0554fdec5 Promote warnings to errors in strtr() 2019-08-22 19:33:37 +02:00
George Peter Banyard
ab76c613fe Normalise strr(i)pos offset messages with str(i)pos ones. 2019-08-22 12:56:32 +02:00
George Peter Banyard
2505edb40d Remove useless error check for bin2hex()
And change prototype accordingly...

Closes GH-4550.
2019-08-16 23:53:53 +02:00
Christoph M. Becker
acac7d1a1a Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78346: strip_tags no longer handling nested php tags
2019-08-02 17:05:01 +02:00
Christoph M. Becker
f12dc90e5e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78346: strip_tags no longer handling nested php tags
2019-08-02 17:04:36 +02:00
Christoph M. Becker
a87ef5e3dd Fix #78346: strip_tags no longer handling nested php tags
When the strip tags state machine has been flattened, an if statement
has mistakenly been treated as else if.  We fix this, and also simplify
a bit right away.
2019-08-02 17:03:20 +02:00
Nikita Popov
36db71df47 Merge branch 'PHP-7.4' 2019-07-22 12:28:40 +02:00
Nikita Popov
46b982409a Deprecate implode() with swapped parameter order 2019-07-22 11:39:52 +02:00
Dmitry Stogov
01d0bd126c Merge branch 'PHP-7.4'
* PHP-7.4:
  vectorize string-escape with NEON
2019-07-15 11:36:11 +03:00
Sebastian Pop
af7639683f vectorize string-escape with NEON
On this benchmark:
function simple_string_escape() {
    $a = "test'asd'asd'' asd\'\"asdfasdf";
    for($i=0; $i<512; $i++) {
        $a .= chr($i%256);
    }
    for ($i = 0; $i < 100000; $i++) {
        if ($a === stripslashes(addslashes($a)))
            $a .= chr($i%256);
        else {
            echo "error at i=".$i."\n";
            return;
        }
    }
}
the execution time goes from 21.619s to 8.139s (165% speedup) on an A1 Graviton instance.

When removing the characters that need escaping, i.e., this benchmark:
function simple_string() {
  $a = "testasdasd asdasdfasdf";
  for ($i = 0; $i < 10000; $i++) {
      if ($a === stripslashes(addslashes($a)))
          $a .= "test dedeasdf";
      else {
          echo "error at i=".$i."\n";
          return;
      }
  }
}
the execution time goes from 2.932s down to 0.516s (468% speedup) on an A1 Graviton instance.
2019-07-15 11:35:08 +03:00
Nikita Popov
8f0729cb65 Merge branch 'PHP-7.4' 2019-06-28 17:47:45 +02:00
Nikita Popov
88d52ae7aa Mark ifunc resolver functions as unused
It looks like clang doesn't see that these are used through
__attribute__((ifunc)) and generates a warning.
2019-06-28 16:55:54 +02:00
Peter Kokot
7f994990ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove HAVE_STRCOLL check
2019-06-28 00:13:25 +02:00
Peter Kokot
638c21765c Remove HAVE_STRCOLL check
The strcoll function is defined in the C89 standard and should be
on today's systems always available via the <string.h> header.

https://port70.net/~nsz/c/c89/c89-draft.html#4.11.4.3

- Remove also SKIPIF strcoll check in test
2019-06-28 00:05:55 +02:00
Nikita Popov
6aaab9adf7 Merge branch 'PHP-7.4' 2019-06-20 16:24:31 +02:00
Nikita Popov
d4de127dd8 In php_needle_char() use well-defined double->integer cast
...by going through zval_get_long(). Generally out of range double
casts are undefined.
2019-06-20 16:22:10 +02:00
Nikita Popov
e8ae19223c Avoid address calculation overflow 2019-06-20 16:22:04 +02:00
Tyson Andre
cdc82f19d8
Fix php 8.0's opcache flags for pathinfo()
See https://php.net/pathinfo

This fixes a bug introduced in the cleanup for commit
0d79c70cf3

`pathinfo($str, PATHINFO_EXTENSION)` will always return a string
(if there is no extension, the function returns the empty string)
2019-06-11 09:09:50 +02:00
Christoph M. Becker
b30d54ce05 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #77937: preg_match failed
2019-06-11 08:45:32 +02:00
Christoph M. Becker
27e592d3ce Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77937: preg_match failed
2019-06-11 08:44:54 +02:00
Christoph M. Becker
b215d1339f Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77937: preg_match failed
2019-06-11 08:44:07 +02:00
Christoph M. Becker
f3ff72e54b Fix #77937: preg_match failed
On some recent Windows systems, ext\pcre\tests\locales.phpt fails,
because 'pt_PT' is accepted by `setlocale()`, but not properly
supported by the ctype functions, which are used internally by PCRE2 to
build the localized character tables.

Since there appears to be no way to properly check whether a given
locale is fully supported, but we want to minimize BC impact, we filter
out typical Unix locale names, except for a few cases which have
already been properly supported on Windows.  This way code like

  setlocale(LC_ALL, 'de_DE.UTF-8', 'de_DE', 'German_Germany.1252');

should work like on older Windows systems.

It should be noted that the locale names causing trouble are not (yet)
documented as valid names anyway, see
<https://docs.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=vs-2019>.
2019-06-11 08:42:32 +02:00