Ticket #313 (closed defect: fixed)

Opened 5 months ago

Last modified 5 months ago

Vertical tab not encoded proprely by serializeJSON

Reported by: sylvain.pasche@gmail.com Assigned to: somebody
Priority: normal Milestone: MochiKit 1.4
Component: component1 Version:
Severity: normal Keywords:
Cc:

Description

MochiKit.Base.serializeJSON("\v");

This returns a vertical tab which is not valid JSON. It should return "\u000b".

Strangely enough, all Javascript letter based control characters (\b, \f, \n, \r, \t) are available in JSON except \v (http://www.json.org/).

Change History

06/24/08 00:00:49 changed by cederberg@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [1390]. Due to the bug being located in repr() for strings, I opted for encoding to \v instead (which is correct ECMAscript according to standard). I suspect that the omission from www.json.org is a specification bug that should be reported and fixed there.

06/24/08 05:42:45 changed by cederberg@gmail.com

  • status changed from closed to reopened.
  • resolution deleted.
  • milestone set to MochiKit 1.4.

Message from Sylvain:

Encoding it as \v is not correct, string "\v" is not valid JSON.

This can be useful: http://deron.meranda.us/python/comparing_json_modules/strings

In my project, I'm using simplejson: simplejson.loads('"\\v"') ValueError?: Invalid \escape: line 1 column 1 (char 1)

06/24/08 05:45:45 changed by cederberg@gmail.com

  • status changed from reopened to closed.
  • resolution set to fixed.

Fixed again in [1391]. The string serialization in serializeJSON has now been completely replaced to one that more closely follows the RFC and json.org specification. The new implementation guarantees that all control characters are escaped and doesn't use \v for vertical tab. Also corrected a corner case where "undefined" could be placed as an array value.