Page MenuHomePhabricator

New function : regex escaping using preg_quote
Closed, ResolvedPublic

Description

Patch for rescape addition (not tested)

Hello,

As a filter editor on frwiki, I build a regexp at runtime using the `article_prefixedtext' variable (it could be another variable). It means that I've to escape the variable because it may contain special characters (parenthesis, for example).

Unfortunately, it looks like there is no function to do this, so I use several str_replace, which is not convenient nor efficient.

I suggest the addition of a new function for regex escaping, using preg_quote.

The attached patch is *only* an example of what it might look like: the code has not been tested at all (I've no local install of mediawiki right now).
If you think this is a good idea, please let me know, and I'll test myself and submit another patch.

Thanks,

Arkanosis @ frwiki


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz24109

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:02 PM
bzimport added a project: AbuseFilter.
bzimport set Reference to bz24109.
bzimport added a subscriber: Unknown Object (MLST).

preg_quote needs two parameters to work properly.

Patch applied in r100135 and r100139. Thanks for submitting it.

(In reply to comment #1)

preg_quote needs two parameters to work properly.

Not really, rlike already takes care of escaping /s.