Closed GoogleCodeExporter closed 9 years ago
I've created a simple testcase to test the issue.
There are 2 different things to discuss here:
1) Serverside "crash" when updating in a callback a TActiveTextBox's Text with
a text that contains accented characters:
This is supposed to work, i suggest you to check your log files to understand
what is failing. The simple testcase i attached is working flawless in my tests.
2) Updating in a callback an active control with some text containing html
entities:
Active controls are updated during callbacks using javascript. Unfortunately
html entities have no "special meaning" in javascript and they are treater as
raw text (see the 2nd and 4th example in the testcase).
The only way to make them work would be to create a html_entity_decode() clone
in javascript and use it everytime we update an active control
(Prado.Element.setValue(), scripaculous-adapter.js:222).
Implementing a base translation matrix (& => &, > => >, ...) can appear like a
simple solution, but as soon as you face the need to detect the text
charset/encoding in order to correctly parse it, you realize that it's an
unnecessary burden.
So, the short answer is: avoid html entities in dynamic controls, check the
error that make php "crash" with accented characters.
Original comment by ctrlal...@gmail.com
on 24 Aug 2013 at 9:52
Attachments:
This is the stack trace.
[Fri Aug 23 15:13:54 2013] [error] [client 127.0.0.1] PHP Fatal error:
Uncaught exception 'Exception' with message 'JSON error (5): Malformed UTF-8
characters, possibly incorrectly encoded' in
/home/marco/NetBeansProjects/Prado-trunk/framework/Web/Javascripts/TJavaScript.p
hp:268\nStack trace:\n#0
/home/marco/NetBeansProjects/Prado-trunk/framework/Web/Javascripts/TJavaScript.p
hp(223): TJavaScript::checkJsonError()\n#1
/home/marco/NetBeansProjects/Prado-trunk/framework/Web/UI/ActiveControls/TActive
PageAdapter.php(350): TJavaScript::jsonEncode(Array)\n#2
/home/marco/NetBeansProjects/Prado-trunk/framework/Exceptions/TErrorHandler.php(
136): TCallbackErrorHandler->displayException(Object(TPhpErrorException))\n#3
/home/marco/NetBeansProjects/Prado-trunk/framework/TApplication.php(1135):
TErrorHandler->handleError(Object(TApplication),
Object(TPhpErrorException))\n#4
/home/marco/NetBeansProjects/Prado-trunk/framework/TApplication.php(416):
TApplication->onError(Object(TPhpErrorException))\n#5
/home/marco/NetBeansProjects/SitoWebSalvaeuro/src/index.php(21):
TApplication->run()\n#6 {main}\n throw in
/home/marco/NetBeansProjects/Prado-trunk/framework/Web/Javascripts/TJavaScript.p
hp on line 268, referer: http://local__myapp/index.php?page=myapp.MakeMeCrash
:/
Original comment by marco.ba...@gmail.com
on 24 Aug 2013 at 11:21
Ok so this is what's going on:
* some code in the page is triggering a php error
* prado translates the error to a TPhpErrorException
* prado's exception handler is trying to display the typical "Exception occurred" page
* the exception message (php's error message) contains a character that is not valid UTF-8, and the application's globalization module doesn't have the Charset property set (so the character is not being translated from a foreign charset to UTF-8).
* the invalid UTF-8 string get passed to json_encode(), that triggers a second exception
* prado won't catch this second exception to avoid a loop
What can cause this? My guess is that one of your source files is not encoded
using UTF-8 while the application declares it should (or doesn't declare it at
all: UTF-8 is prado's default encoding).
Try checking with file --mime:
Lapidus:~ fab$ file --mime test.php
test.php: text/x-php; charset=utf-8
Lapidus:~ fab$ file --mime test.php
test.php: text/x-php; charset=iso-8859-1
Original comment by ctrlal...@gmail.com
on 25 Aug 2013 at 1:33
[deleted comment]
Original comment by ctrlal...@gmail.com
on 3 Sep 2013 at 10:20
Original issue reported on code.google.com by
marco.ba...@gmail.com
on 23 Aug 2013 at 1:19