Bug #76999 [Opn->Ver]: mb-regex-set-options return current options

From: Date: Thu, 11 Oct 2018 13:52:01 +0000
Subject: Bug #76999 [Opn->Ver]: mb-regex-set-options return current options
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217516@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76999&edit=1

 ID:                 76999
 Updated by:         cmb@php.net
 Reported by:        kay dot lukas at gmail dot com
 Summary:            mb-regex-set-options return current options
-Status:             Open
+Status:             Verified
 Type:               Bug
-Package:            *Regular Expressions
+Package:            mbstring related
 Operating System:   Mac OSX
 PHP Version:        7.1.22
 Block user comment: N
 Private report:     N

 New Comment:

Confirmed: <https://3v4l.org/5fiCT>.


Previous Comments:
------------------------------------------------------------------------
[2018-10-11 13:17:02] kay dot lukas at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/function.mb-regex-set-options
---

The documentation says that mb_regex_set_options should return the previous results, 

> The previous options. If options is omitted, it returns the string that describes the current
> options.


This is quite useful so you can change the options and easily set it back to the defaults after you
are done with mb_regex. However, it seems to do something totally different, returning the current
options instead.

It seems like the internal function is designed for it:

https://github.com/php/php-src/blob/a5e80b22e11c2db7fd5ff07b5b7a28f80745e89b/ext/mbstring/php_mbregex.c#L1624

however this functionality is not used in the wrapping function:

https://github.com/php/php-src/blob/a5e80b22e11c2db7fd5ff07b5b7a28f80745e89b/ext/mbstring/php_mbregex.c#L1660

null is passed in.

Test script:
---------------
```
php > var_dump(mb_regex_set_options("m"));
string(2) "mr"
php > var_dump(mb_regex_set_options("mdi"));
string(3) "imd"
php > var_dump(mb_regex_set_options("m"));
string(2) "mr"
php > var_dump(mb_regex_set_options("a"));
string(1) "r"
```



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76999&edit=1


Thread (4 messages)

« previous php.bugs (#217516) next »