Last modified: 2011-10-18 18:14:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T26109, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24109 - New function : regex escaping using preg_quote
New function : regex escaping using preg_quote
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
AbuseFilter (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-24 10:36 UTC by Jérémie Roquet
Modified: 2011-10-18 18:14 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch for rescape addition (not tested) (1.80 KB, patch)
2010-06-24 10:36 UTC, Jérémie Roquet
Details

Description Jérémie Roquet 2010-06-24 10:36:03 UTC
Created attachment 7507 [details]
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
Comment 1 Niklas Laxström 2010-06-24 10:53:10 UTC
preg_quote needs two parameters to work properly.
Comment 2 Victor Vasiliev 2011-10-18 17:58:42 UTC
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.
Comment 3 Jérémie Roquet 2011-10-18 18:14:55 UTC
Hi Victor, thanks! :-)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links