Deprecate mb_ereg_replace eval option View as Markdown

Implemented (PHP 7.1)
Authors
Rouven Weßling, me@rouvenwessling.de
Date
2016-01-04
Version
1.0
Source
wiki.php.net/rfc/deprecate_mb_ereg_replace_eval_option

Vote

Deprecate mb_ereg_replace eval option closed
Yes
19
No
0
19 voters
aharvey Yes 2016-02-03 22:44
ajf Yes 2016-01-30 16:19
bishop Yes 2016-01-28 14:48
colinodell Yes 2016-01-30 16:21
danack Yes 2016-01-28 12:40
fa Yes 2016-01-29 12:34
gasolwu Yes 2016-01-28 10:31
guilhermeblanco Yes 2016-02-04 03:23
jhdxr Yes 2016-02-01 16:40
leigh Yes 2016-02-01 10:38
levim Yes 2016-01-28 14:14
mightyuhu Yes 2016-01-30 19:04
nikic Yes 2016-01-28 10:14
ocramius Yes 2016-01-28 10:22
pmjones Yes 2016-02-04 19:11
ryat Yes 2016-01-29 01:12
sammyk Yes 2016-02-04 19:01
stas Yes 2016-01-28 18:10
tpunt Yes 2016-01-28 10:34

Discussions on the mailing list

RFC: Deprecate mb_ereg_replace eval option
· 7 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC

Introduction

This RFC aims at deprecating the e option that mb_ereg_replace and mb_eregi_replace provide.

Problems

The e option evaluates arbitrary PHP code it can easily be exploited if user input is not carefully validated or sanitized.

Didn't we already do that?

No. Around 4 years ago a RFC was passed to deprecate a similar options in preg_replace. This was executed in PHP 5.5 (deprecation) respectively PHP 7 (removal). That a similar option is present in mb_ereg_replace was apparently overlooked.

Proposal

Emit an E_DEPRECATED error whenever mb_ereg_replace or mb_eregi_replace is called with the e option.

Backward Incompatible Changes

Once the feature is actually removed, any code relying on it will break. Whether silently or with an error will be left to decide in the removal RFC.

The suggested replacement, mb_ereg_replace_callback is has only been available since PHP 5.4.1. Projects which support both PHP 5.3 and PHP 7.1 may need two code paths to avoid deprecation warnings.

There is no mb_eregi_replace_callback function. Code using it will have to be converted to use mb_ereg_replace_callback with the i option.

Future Scope

The removal of this feature is not part of this RFC. This should be done, when a release, where this is possible, is actually on the agenda.

Proposed Voting Choices

Should an E_DEPRECATED error be emitted whenever mb_ereg_replace or mb_eregi_replace is called with the e option?

This vote will require a 50%+1 majority.

Voting opened on January 28th 2016, to close on February 4th.

Vote: Deprecate mb_ereg_replace eval option — Yes: 19 · No: 0 (closed)

Patches and Tests

A patch is available: <https://github.com/php/php-src/pull/1994> (merged).

References

RFC: Remove preg_replace /e modifier