#6167: $javascript->Object() fails on creating JSON for already scaped strings ------------------------+--------------------------------------------------- Reporter: MoNKi | Owner: mark_story Type: Bug | Status: reopened Priority: Medium | Milestone: 1.2.x.x Component: Helpers | Version: 1.2 Final Severity: Normal | Resolution: Keywords: | Php_version: n/a Cake_version: | ------------------------+--------------------------------------------------- Changes (by ddaffy):
* status: closed => reopened * resolution: fixed => Comment: I have the same problem.. when array contains escaped string with newline characters or just '\n', $javascript->object() with '''$useNative''' set to '''false''' (PHP<5.2) returns invalidly escaped JSON. {{{ $data = array(); $data[] = $javascript->escapeString("Some string with\nline break"); // same with $data[] = $javascript->escapeString('Some string with\nline break'); $javascript->useNative = true; echo $javascript->object($data); $javascript->useNative = false; echo $javascript->object($data); }}} Output is (PHP 5.2.8): {{{ ["Some string with\\nline break"] ["Some string with\nline break"] }}} Second string can't be '''eval()'''d properly in JS because of non-escaped '\n' in it. -- Ticket URL: <https://trac.cakephp.org/ticket/6167#comment:5> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---