ZF-9656: Zend_Amf: unable to handle paranthesis in webroot path

Issue Type: Bug Created: 2010-04-12T03:13:45.000+0000 Last Updated: 2013-02-14T15:40:03.000+0000 Status: Open Fix version(s): Reporter: Anand Gaurav (angaurav) Assignee: None Tags: - Zend_Amf

Related issues: Attachments: - amf_config.ini


Zend_Amf framework is unable to handle parenthesis as path for webroot. Here is the error log that I got in my usecase:

<pre class="highlight">
Warning: parse error in amf_config.ini on line 5 in gateway.php on line 12

Fatal error:
Uncaught exception 'Zend_Config_Exception' with message 'parse error in amf_config.ini on line 5' in Zend\Config\Ini.php:181

Stack trace:

#0 Zend\Config\Ini.php(201): Zend_Config_Ini->_parseIniFile('C:\wamp\www\Fle...')
#1 Zend\Config\Ini.php(125): Zend_Config_Ini->_loadIniFile('C:\wamp\www\Fle...')
#2 gateway.php(31): Zend_Config_Ini->__construct('C:\wamp\www\Fle...', 'zendamf')
#3 {main} thrown in Zend\Config\Ini.php on line 181

Steps to produce:

  1. Have a webroot dir which contains paranthesis. eg. "C:/wamp/abc()"
  2. Two files have been attached: gateway.php and amf_config.ini. Put these files into the webroot folder
  3. open gateway.php in browser. (http://localhost/gateway.php)

Note: the amf_config.ini has this entry in 5th line:



### Comments

Posted by Josh Jensen (captaincode) on 2010-05-03T14:31:39.000+0000

This error makes it impossible to utilize Zend\_Amf w/ Flash Builder and Zend Server CE on a 64 bit system as the server is installed in "Program Files (x86)".



Posted by Daniel Mera (danmera) on 2010-11-17T17:49:28.000+0000

How I got around this error.... Well I uninstalled the Zend Community Server and did a new installation.. this time when I installed it and asked to install the apache server I installed it in a different folder, not the "Program Files (x86)", and it worked like a charm.. well had to direct the files from my flex project also.. but the zend server works



Posted by Saulo Batista Borges (saulobborges) on 2013-02-14T14:52:58.000+0000


<?php ini\_set("display\_errors", 1); $dir = dirname(**FILE**); $webroot = $\_SERVER['DOCUMENT\_ROOT']; $configfile = "$dir\\amf\_config.ini";

//default zend install directory $zenddir = $webroot. '/ZendFramework/library/';

//Load ini file and locate zend directory if(file\_exists($configfile)) { $arr=parse\_ini\_file($configfile,true); if(isset($arr['zend']['webroot'])){ $s1 = array('(', ')'); $s2 = array(chr(28), chr(29)); $webroot = str\_replace($s1, $s2, $arr['zend']['webroot']); $zenddir = $webroot. '/ZendFramework/library/'; } if(isset($arr['zend']['zend\_path'])){ $zenddir = $arr['zend']['zend\_path']; } }

// Setup include path //add zend directory to include path set\_include\_path(get\_include\_path().PATH\_SEPARATOR.$zenddir); // Initialize Zend Framework loader require\_once('Zend/Loader/Autoloader.php'); Zend\_Loader\_Autoloader::getInstance()->setFallbackAutoloader(true);

// Load configuration $default\_config = new Zend\_Config(array("production" => false), true); $default\_config->merge(new Zend\_Config\_Ini($configfile, 'zendamf')); $default\_config->setReadOnly(); $amf = $default\_config->amf;

// Store configuration in the registry Zend\_Registry::set("amf-config", $amf); // Initialize AMF Server $server = new Zend\_Amf\_Server(); $server->setProduction($amf->production); if(isset($amf->directories)) { $dirs = $amf->directories->toArray(); foreach($dirs as $dir) { // get the first character of the path. // If it does not start with slash then it implies that the path is relative to webroot. Else it will be treated as absolute path $length = strlen($dir); $firstChar = $dir; if($length >= 1) $firstChar = $dir[0];

        if($firstChar != "/"){
            // if the directory is ./ path then we add the webroot only.
            if($dir == "./"){               
                $tempPath = $webroot . "/" . $dir;

} // Initialize introspector for non-production if(!$amf->production) { $server->setClass('Zend\_Amf\_Adobe\_Introspector', '', array("config" => $default\_config, "server" => $server)); $server->setClass('Zend\_Amf\_Adobe\_DbInspector', '', array("config" => $default\_config, "server" => $server)); } // Handle request echo $server->handle();



Posted by Frank Br├╝ckner (frosch) on 2013-02-14T15:37:24.000+0000

Hi Saulo, can you add the code tags to your comment:

    <pre class="highlight">





Have you found an issue?

See the Overview section for more details.


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

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