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


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

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:



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)".

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


<?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();

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