"GICodeWarrior" posted a comment on MediaWiki.r102587.
URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/102587#c27382

Commit summary for MediaWiki.r102587:

Add wfRemoveDotSegments and unit tests.  This is a sane step towards fixing
bug 32168.  This implements RFC3986 Section 5.2.4.
http://tools.ietf.org/html/rfc3986#section-5.2.4

This is important because you need to remove dot segments in order to safely
compare URLs when limiting URLs to a particular path.

GICodeWarrior's comment:

Step A matches ./ and ../ each only if they are at the beginning of the string. 
 Step B matches /./ or /. followed by the end of the string.

Both steps are matching two different possible strings.

Even if they were each matching only one, I am pretty sure a preg_match 
anchored to the beginning of the string while using only ? as a wildcard and | 
as a combinator followed by a boolean test is much faster than creating new 
strings and running a string comparison.  Anchored, greedy regular expressions 
are generally quite fast.

If you think this implementation is particularly slow or in a critical path, 
perhaps we should run a performance test.

The usage of $start keeps the subsequent line under 80 characters.  They can 
certainly be inlined if that is the preferred style.

If you find an implementation in PEAR, please let me know.  I did a fair bit of 
searching for a PHP implementation of this RFC.  The best attempt I could find 
was a ragged/"clever" patch for something Drupal related.

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to