Hi,
I've investigated a bit and found the place where the problem occurs.
JSON.php (lines 716-721):
<code>
716: } elseif (($chrs{$c} == $top['delim']) &&
717: ($top['what'] == SERVICES_JSON_IN_STR) &&
718: (($chrs{$c - 1} != '\\') ||
719: ($chrs{$c - 1} == '\\' && $chrs{$c - 2} == '\\'))) {
720: // found a quote, we're in a string, and it's not escaped
721: array_pop($stk);
</code>
The problem is that the expression in line 719 evaluates to true.
The line looks like it tries to handle any escaped backslash (\\) inside the
string just prior to string-end delimiter ("). But in my case it falsely
evaluates to true.
I could easily add another special check somewhere between lines 718 and 719
that handles my special case, but there should be a general solution, I think.
For the overview, here's the situation when we reach the problem:
<pre>
+--------------
| +----------- $chrs{ c-2 }
| | +-------- $chrs{ c-1 }
| | | +----- $chrs{ c }
| | | | +-- $chrs{ c+1 }
v v v v v
[\][\][\]["]["]
</pre>
Is there anybody that knows a good solution for this? I am not happy with my
'special check' that handles just my special issue.
Peter
> Hi Group,
>
> When I input a backslash followed by double-quotas and try to send it via JSON
> to my (PHP-)backend, the "decode()" Method of JSON class fails :(
> The input comes from an TextField, where this has to be allowed!
> The frontend side seems to encode the data correct (see below):
>
> {"service":"test_n_debug.rpcTest","method":"echo","id":10,"params":["\\\""],"server_data":null}
>
> JSONlint [1] also validates this as "Valid JSON". But the backend fails to
> decode it.
> Does anybody have the knowledge why the PHP backend chokes on this?
> Any help/tip/hint would be appreciated. I don't know if this issue is present
> in the other backend implementations (Java,Pearl,Pyhon) too, but should be
> checked anyway.
>
> Regards,
> Peter
>
>
> [1] http://www.jsonlint.com/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel