[wp-trac] [WordPress Trac] #26174: Customizer postMessage listener throws errors if it encounters a non-JSON string

WordPress Trac noreply at wordpress.org
Fri Nov 22 21:32:15 UTC 2013


#26174: Customizer postMessage listener throws errors if it encounters a non-JSON
string
--------------------------+-----------------------------
 Reporter:  mattwiebe     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Appearance    |    Version:
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 Our postMessage listener in `wp-includes/js/customize-base.js` assumes
 that every possible postMessage message that comes in from the same domain
 as the Customizer must have an `event.data` property that is 1) a string
 and 2) a good candidate for `JSON.parse`.

 Both of these assumptions are faulty, since 1) non-IE browsers can pass
 objects, not just strings, and 2) sending a string that can't be
 `JSON.parse`'d is a perfectly valid thing to do. As more things start to
 use `postMessage`, this will get us into more trouble. (In this case it's
 Google+ Follow embeds, which receive "lovely" strings like
 `"!_{h:'I0_1385142794503'}"` which `JSON.parse` of course chokes on.

 Patch included.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/26174>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list