ZF-7902: Zend_Filter_StringTrim does not work when trim string is '/'


Zend_Filter_StringTrim no longer works (i just upgraded from 1.7.3) when the string you wish to trim is '/'.

I get this warning and Zend_Filter_StringTrim::filter returns 0 Warning: preg_replace() [function.preg-replace]: Unknown modifier ']' in Zend/Filter/StringTrim.php on line 112

How to replicate: $stringTrim = new Zend_Filter_StringTrim('/'); $stringTrim->filter('/some/uri/here/');


The issue is caused by the forward slash also being the delimiter in the regular expression used. I've prepared a patch that escapes the forward slash properly.

Patch for ZF-7902

(sorry for the duplicate upload, but got a stacktrace on the first try. deleting one of the files.)

Fixed with r18399. Thnx for the patch.

This issue still present in version 1.9.7

This issue is marked as fixed for the next minor release which is 1.10. Otherwise "Fix-Version" would point to a defined release where this issue has been solved.

IMHO the test case for this issue does not check for the bug reported here. Attaching a changed test case.