ZF-2538: Zend_Filter_Inflector::filter() fails with all numeric folder on Windows

Issue Type: Bug Created: 2008-01-31T14:10:31.000+0000 Last Updated: 2008-03-21T16:25:44.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Rob Allen (rob) Assignee: Ralph Schindler (ralph) Tags: - Zend_Filter_Inflector

Related issues: Attachments:



I think we've found a bug in Zend_Filter_Inflector::filter() when using Windows and a module directory that contains a folder consisting entirely of numbers.

The problem manifests itself on line 150 of Inflector.php:

$inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->_target);

In our case input data is: $processedParts: array(2) { ["#:suffix#"] => "phtml" ["#:moduleDir#"] => "D:\htdocs\HEAD\24074\app\modules\default" }

$this->_target : ":moduleDir/views"

And the result is:

$inflectedTarget: "D:\htdocs\HEAD074\app\modules\default/views"

If we use a module dir of "D:/htdocs/HEAD/24074/app/modules" then the problem goes away. Similarly a module dir of "D:\htdocs\HEAD\a24074\app\modules\default" also works.

Note that it doesn't matter what the number is, in all cases, the first two digits, along with the precending backslash are removed. I suspect it's related to preg_replace's parameter substitution.


Posted by Matthew Weier O'Phinney (matthew) on 2008-02-04T15:30:02.000+0000

Assigning to Ralph

Posted by Miroslav Kubelik (koubel) on 2008-02-05T02:07:18.000+0000

Yes, I found the same problem, simple workaround is (tested only on windows)

<pre class="highlight">
$ diff -Naur \
 /c/Program\ Files/Apache\ Group/Apache2/htdocs/zftrunk/library/Zend/Filter/Inflector.php.orig  \
 /c/Program\ Files/Apache\ Group/Apache2/htdocs/zftrunk/library/Zend/Filter/Inflector.php 
--- /c/Program Files/Apache Group/Apache2/htdocs/zftrunk/library/Zend/Filter/Inflector.php.orig Tue Dec 11 14:29:34 2007
+++ /c/Program Files/Apache Group/Apache2/htdocs/zftrunk/library/Zend/Filter/Inflector.php      Tue Feb  5 08:00:54 2008
@@ -443,6 +443,7 @@
                    $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = $processedPart;
            } elseif (is_string($ruleValue)) {
+                $ruleValue=str_replace("\\","\\\\",$ruleValue);
                 $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = $ruleValue;

Posted by Ralph Schindler (ralph) on 2008-02-15T11:20:33.000+0000

FIxed in r8036.

Added str_replace() to disable possible backreference like syntax inside replacement strings.


Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.