The inline editor widget reports a JSON error when saving non-ASCII characters

Bug #331990 reported by Māris Fogels
156
This bug affects 34 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Leonard Richardson
lazr.restful
Fix Released
High
Leonard Richardson

Bug Description

When saving a Bug title that contains unicode characters, using the Inline Editor widget, you receive the following error:

"Entity-body was not a well-formed JSON document."

The server returns a response code of 400, Bad Request.

At a glance, the JSON string being sent to the server appears to be well-formed, but this should be verified using the JSON parsers on both the client and server.

Māris Fogels (mars)
Changed in launchpad-foundations:
assignee: nobody → mars
importance: Undecided → High
status: New → Triaged
summary: - The inline editor widget reports a JSON error when saving Unicode
+ The inline editor widget reports a JSON error when saving non-ASCII
characters
Revision history for this message
Philipp Kempgen (philipp-kempgen) wrote :

Here's roughly how to escape the string:

String.prototype.toJSON = function()
{
 return '\''+ this.replace(/[\\"'\x00-\x1F\u0080-\uFFFF]/g, function(c) {
  switch (c) {
   case "\b": return '\\b';
   case "\t": return '\\t';
   case "\n": return '\\n';
   case "\f": return '\\f';
   case "\r": return '\\r';
   case '"' : return '\\"';
   case '\'': return '\\\'';
   case '\\': return '\\\\';
  }
  return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);
 }) +'\'';
}

Revision history for this message
Adi Roiban (adiroiban) wrote :

maybe this bug is critical as with the new UI new user will not use the old „Update description / tags” link

Revision history for this message
Michael B. Trausch (mtrausch) wrote :

I just tried this on bug 311908, where I went to use “Dock”, but had to type "dock" in order to get it to submit.

Changed in launchpad-foundations:
assignee: Māris Fogels (mars) → Tom Berger (intellectronica)
milestone: none → 2.2.6
Revision history for this message
Māris Fogels (mars) wrote :

Yes, this bug should be treated as critical, as it makes editing various titles impossible.

It is most likely a problem with the back-end webservice. JSON is unicode, there should not be a problem transmitting the data to and from the server.

Revision history for this message
Eleanor Berger (intellectronica) wrote :

This is a bug in lazr.restful. I've got a fix for it

Changed in lazr.restful:
assignee: nobody → Tom Berger (intellectronica)
importance: Undecided → High
status: New → In Progress
Changed in launchpad-foundations:
status: Triaged → In Progress
Revision history for this message
Eleanor Berger (intellectronica) wrote :
Changed in lazr.restful:
status: In Progress → Fix Committed
Changed in launchpad-foundations:
status: In Progress → Fix Committed
Changed in lazr.restful:
status: Fix Committed → Fix Released
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
Revision history for this message
Dmitry Agafonov (dmitry-agafonov) wrote :

Not fixed (or re-appeared in new LP version).
Trying to edit bug description or assign it via ajax I'm getting error 400.

Revision history for this message
Eleanor Berger (intellectronica) wrote :

Dmitry, can you please provide more information about the failure you're experiencing?

1. Is it plausibly due to non-ascii characters (that is, are there any non-ascii characters in the description)?
2. What bug are you trying to edit?
3. What browser are you using?

Revision history for this message
Dmitry Agafonov (dmitry-agafonov) wrote :

1. Non-ascii characters are present.
2. https://bugs.launchpad.net/ubuntu-ru/+bug/441424
3. Mozilla/5.0 (X11; U; Linux i686; ru; rv:1.9.0.14) Gecko/2009090216 Ubuntu/8.04 (hardy) Firefox/3.0.14

Revision history for this message
Adi Roiban (adiroiban) wrote :

I can confirm that this bug is not fixed in Launchpad 3.0 (r9636).

Just go to any bug title or description and try to add one of these characters „ș” or „ț”.

I hope that inline editor will allow all unicode characters.

Revision history for this message
Eleanor Berger (intellectronica) wrote :

I can confirm that this fix isn't available in LP. We've switched to using a newer version of lazr.restful that doesn't have this fix as part of the move to buildout. To re-fix this bug we need to forward port this fix into the current lazr.restful and include an egg with these revisions for inclusion in LP.

Changed in launchpad-foundations:
status: Fix Released → Triaged
milestone: 2.2.6 → none
assignee: Tom Berger (intellectronica) → nobody
Changed in lazr.restful:
status: Fix Released → Triaged
assignee: Tom Berger (intellectronica) → Leonard Richardson (leonardr)
Changed in lazr.restful:
status: Triaged → Fix Released
Revision history for this message
Dmitry Agafonov (dmitry-agafonov) wrote :

From #launchpad conversation:
- are there workarounds?
- For now, use the non-AJAX forms, add /+edit or /+editstatus to the bug URL.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

You can also right-click on the edit button and Open Link in New Tab.

Revision history for this message
jhfhlkjlj (fdsuufijjejejejej-deactivatedaccount) wrote :

Fix released? I just encountered the bug myself.

Revision history for this message
jpfle (jpfle) wrote :

I confirm that the bug is still there. I've just encountered it for https://bugs.launchpad.net/ubuntu/+source/phpmyadmin/+bug/456319

Revision history for this message
Māris Fogels (mars) wrote :

@Chauncellor, it has been marked as "Fix Released" in the underlying lazr.restful library. It looks like the Foundations team still has to verify that the new lazr.restful has been pulled into the Launchpad source tree. If it has been pulled in then the fix should show up on edge.launchpad.net.

Revision history for this message
Leonard Richardson (leonardr) wrote :

I've confirmed that the bug is gone in edge.launchpad.net, which uses the new library.

Revision history for this message
Diogo Matsubara (matsubara) wrote :

Set foundations task as fix committed per r9689 <http://bazaar.launchpad.net/~launchpad-pqm/launchpad/stable/revision/9689>
Leonard tried to reproduce on edge and I tried on staging and both of us couldn't reproduce on those. Production will be updated in the next release.

Changed in launchpad-foundations:
status: Triaged → Fix Committed
assignee: nobody → Leonard Richardson (leonardr)
milestone: none → 3.1.10
Changed in lazr.restful:
milestone: none → 0.9.11
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
Revision history for this message
Dmitry Agafonov (dmitry-agafonov) wrote :

Not fixed, even on edge...

Revision history for this message
Dmitry Agafonov (dmitry-agafonov) wrote :

Oh, sorry. Works for bug title and description inline editors.
Not fixed for "Assigned to..." ajax popup.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.