Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json posts failing with encoding problems in 3.2.11 #9071

Closed
timuckun opened this issue Jan 25, 2013 · 8 comments
Closed

Json posts failing with encoding problems in 3.2.11 #9071

timuckun opened this issue Jan 25, 2013 · 8 comments

Comments

@timuckun
Copy link

When I execute the following

curl -H "Content-Type: application/json" -d '{"data": {"firstname": "Ninh","lastname": "Vo","email": "ninh.vo@texodesign.com","password": "khongtuu","phone": "+84904493642" },  "device_id": "222222" }'  -X POST http://localhost:3000/api/v1/salesperson/register -i

I get the following error

MultiJson::DecodeError (lexical error: invalid char in json text.
          ","phone": "+84904493642" },  "device_id": "222222" }
                     (right here) ------^

The right there is pointing to the quote which is apparently in a non UTF8 encoding.

Removing that quote leads to other errors on other characters so clearly the JSON parser is not coping with the encoding properly.

The full stack trace is here https://gist.github.com/4632520

@steveklabnik
Copy link
Member

I cannot reproduce this. When I copy/paste your curl and run it against an app of mine, everything parses correctly. This is against master, anyway.

Are you sure you're not sending strange quote characters?

@steveklabnik
Copy link
Member

Also tried on 3.2.11, works just fine.

@timuckun
Copy link
Author

It doesn't surprise me that you can't duplicate the problem. Chances are the act of pasting it into this text box converts it somehow.

I don't know what encoding the client is using but he is in Vietnam and is using windows.

@steveklabnik
Copy link
Member

😢

GitHub should support UTF8, but given that he's pasting it to you, I assume, the issue might happen between then and now.

Is there any way I can get some way to reproduce this? Otherwise, I can't do anything about it. 😦

@drbrain
Copy link

drbrain commented Jan 27, 2013

This may be relevant, ruby doesn't support Windows-1258 encoding at this time: https://bugs.ruby-lang.org/issues/7742

@timuckun
Copy link
Author

AAAUUUGGGGGHHHH.

On the off chance that I am NOT tripping over this but is there any way to configure rails so that all JSON posts are automatically (and forcefully) converted to UTF8? I can give the client back a sane error message if the conversion is not perfect but currently it causes an exception.

@mikepmunroe
Copy link
Contributor

@timuckun, any update on this? Is it possible that you received more information after your most recent comment that could be of help in trying to reproduce the problem?

@arunagw
Copy link
Member

arunagw commented Jun 23, 2013

@timuckun closing this issue for now.

Please reopen again if this problem still persist.

thanks

@arunagw arunagw closed this as completed Jun 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants