]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.0' into PHP-7.1
authorChristoph M. Becker <cmb@php.net>
Thu, 28 Jul 2016 13:35:56 +0000 (15:35 +0200)
committerChristoph M. Becker <cmb@php.net>
Thu, 28 Jul 2016 13:50:41 +0000 (15:50 +0200)
# Resolved conflicts:
# ext/mbstring/php_mbregex.c

1  2 
NEWS
ext/mbstring/php_mbregex.c
ext/mbstring/tests/mb_ereg_search_setpos.phpt

diff --cc NEWS
index 1e346f0640b5c5e76810349a01b44f7563402278,63ffcee1920cf119d158e6f1e413776ef90b2f6a..55258ed69e380493b6e234684a156902f3f3e880
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -23,12 -61,14 +23,14 @@@ PH
  - mbstring:
    . Fixed bug #72691 (mb_ereg_search raises a warning if a match zero-width).
      (cmb)
-   . Fixed Bug #72693 (mb_ereg_search increments search position when a match
+   . Fixed bug #72693 (mb_ereg_search increments search position when a match
      zero-width). (cmb)
+   . Fixed bug #72694 (mb_ereg_search_setpos does not accept a string's last
+     position). (cmb)
  
 -- Opcache:
 -  . Fixed bug #72590 (Opcache restart with kill_all_lockers does not work).
 -    (Keyur)
 +- Mysqlnd:
 +  . Fixed bug #71863 (Segfault when EXPLAIN with "Unknown column" error when
 +    using MariaDB). (Andrey)
  
  - PCRE:
    . Fixed bug #72688 (preg_match missing group names in matches). (cmb)
index 3b5e8572897e4f68c47191222650430932790d5d,fc0b1d43e2c3a89dac496f72b70d809a5e468d93..fd103abf195aa8dc21579b7fea64bbdd41056b7e
@@@ -1441,12 -1408,7 +1441,12 @@@ PHP_FUNCTION(mb_ereg_search_setpos
                return;
        }
  
-       if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && (size_t)position >= Z_STRLEN(MBREX(search_str)))) {
 +      /* Accept negative position if length of search string can be determined */
 +      if ((position < 0) && (!Z_ISUNDEF(MBREX(search_str))) && (Z_TYPE(MBREX(search_str)) == IS_STRING)) {
 +              position += Z_STRLEN(MBREX(search_str));
 +      }
 +              
+       if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && (size_t)position > Z_STRLEN(MBREX(search_str)))) {
                php_error_docref(NULL, E_WARNING, "Position is out of range");
                MBREX(search_pos) = 0;
                RETURN_FALSE;
index ec354309f3f12fa3db18498cf88feec863397f82,0000000000000000000000000000000000000000..0a4c18473bb8cc60a2360e9ba1e0987cf181b1a4
mode 100644,000000..100644
--- /dev/null
@@@ -1,70 -1,0 +1,70 @@@
- $positions = array( 5, 19, 20, 25, 0, -5, -20, -30);
 +--TEST--
 +mb_ereg_search_setpos() function
 +--SKIPIF--
 +<?php
 +if (!extension_loaded('mbstring')) die('skip mbstring not enabled');
 +?>
 +--FILE--
 +<?php
 +mb_regex_encoding('iso-8859-1');
 +$test_str = 'Iñtërnâtiônàlizætiøn'; // Length = 20
 +
 +var_dump(mb_ereg_search_setpos(50)); // OK
 +var_dump(mb_ereg_search_setpos(-1)); // Error
 +
 +mb_ereg_search_init($test_str);
 +
- * Position: 19 :
++$positions = array( 5, 20, 21, 25, 0, -5, -20, -30);
 +foreach($positions as $pos) {
 +      echo("\n* Position: $pos :\n");
 +      var_dump(mb_ereg_search_setpos($pos));
 +      var_dump(mb_ereg_search_getpos());
 +}
 +?>
 +==DONE==
 +--EXPECTF--
 +bool(true)
 +
 +Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
 +bool(false)
 +
 +* Position: 5 :
 +bool(true)
 +int(5)
 +
- int(19)
++* Position: 20 :
 +bool(true)
- * Position: 20 :
++int(20)
 +
++* Position: 21 :
 +
 +Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
 +bool(false)
 +int(0)
 +
 +* Position: 25 :
 +
 +Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
 +bool(false)
 +int(0)
 +
 +* Position: 0 :
 +bool(true)
 +int(0)
 +
 +* Position: -5 :
 +bool(true)
 +int(15)
 +
 +* Position: -20 :
 +bool(true)
 +int(0)
 +
 +* Position: -30 :
 +
 +Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
 +bool(false)
 +int(0)
 +==DONE==
 +
 +