Issues

ZF-8603: Zend_Json_Server does not allow namespaces that start with numbers

Description

-- Steven Brown steven@yewchube.com wrote (on Monday, 21 December 2009, 02:42 PM +1000):

I'm implemented a JSON-RPC server, but I've been snagged.

The namespace I want to use starts with a number.

This namespace does not pass the regular expressions that validate the namespaces in Zend_Json_Server_Smd_Service and Zend_Json_Server_Request, as a result the JSON-RPC server does not work.

If I remove the regular expression checks the code all works fine.

Given that namespaces starting with numbers are allowed in JSON-RPC, why are they being blocked in Zend_Json_Server?

Please don't suggest that I use a different namespace, due to forces outside of my control this would be a major headache.

Actually, there's really no reason to do so. My original thought on the matter was that it was a PHP limitation -- that we were mapping namespaces directly to PHP classes as a 1:1 mapping. However, that's not the case -- the namespace maps to a class, but they do not have to match.

Please file an issue in the tracker for this. In the meantime, simply extend Zend_Json_Server locally, and override the method that does the namespace check.

-- Matthew Weier O'Phinney Project Lead | matthew@zend.com Zend Framework | http://framework.zend.com/

Comments

Eclipse Workspace Patch 1.0

P Zend Framework Trunk

Index: library/Zend/Json/Server/Request.php

--- library/Zend/Json/Server/Request.php (revision 20162) +++ library/Zend/Json/Server/Request.php (working copy) @@ -51,7 +51,7 @@ * Regex for method * @var string / - protected $methodRegex = '/^[a-z][a-z0-9.]$/i'; + protected $methodRegex = '/^[a-z0-9][a-z0-9.]*$/i';

 /**
  * Request parameters

Eclipse Workspace Patch 1.0

P Zend Framework Trunk

Index: library/Zend/Json/Server/Smd/Service.php

--- library/Zend/Json/Server/Smd/Service.php (revision 20162) +++ library/Zend/Json/Server/Smd/Service.php (working copy) @@ -58,7 +58,7 @@ * Regex for names * @var string */ - protected $_nameRegex = '/^[a-z][a-z0-9._]+$/i'; + protected $_nameRegex = '/^[a-z0-9][a-z0-9._]+$/i';

 /**
  * Parameter option types

Sorry, seems patches in comments don't work