slashes being replaced by \/ on a Zend Dojo Form
I'am doing this: http://zend-framework-community.634137.n4.nabble.com/How-to-Zend-Dojo-Form-Dependent-Selects-e-g-Country-City-td663650.html
If i do this:
$this->view->form->getElement('subtipo')->setStoreParams(array('url'
=> 'http://localhost/~xpete/project/public/info/lookup/tipo/1'));
I get this result on the generated html/js:
subtipo_id = new dojo.data.ItemFileReadStore({"url":"http:\/\/localhost\/~xpete\/project\/public\/info\/lookup\/tipo\/1"});
开发者_如何学JAVA
The \
have been replaced by \/
.
Is there any way I can avoid this? Is this is a Zend bug?
I tried this with Zend FW 1.11.7 1.11.8 and 1.11.9 preview. I tried with both magic quotes on and off and the result is the same. I am using php 5.3.7 so magic quote are disabled by default.
setStoreParams
is a method from the Zend Framework and that's why I think this may be a bug.
Here's some links describing some of the behavior you see in PHP:
http://www.php.net/manual/en/function.json-encode.php#100679
https://bugs.php.net/bug.php?id=49366
The result is that an flag is being created for PHP 5.4 (which is currently in alpha) to be able to not escape the slashes. I have not seen if this was backported to the 5.3 branch or not.
As the (hopefully) final release of ZendFramework 1 was today, you could modify the Zend_Json::encode method to how you would like. Have it look for strings that start with 'http://' and strip the slashes back off.
That's not a bug. It's common practice to escape a forward slash /
that is in double quotes to avoid javascript errors. When Javascript writes this as a string, it will only write http://localhost/~xpete/project/public/info/lookup/tipo/1
You have to replace "/" text in user interface using str_replace("/","",your_string)
.
精彩评论