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

Remove non-UTF-8 characters from format before generating JSON error #2234

Merged
merged 3 commits into from
Jan 11, 2022

Conversation

bschmeck
Copy link
Contributor

If we receive a request with an unsupported format, that user-provided format is included in the generated error message. If the format includes non-UTF-8 characters and the app is configured to generate JSON error messages, a JSON::GeneratorError is raised.

To work around this error, this PR uses String#encode's ability to replace invalid and undefined UTF-8 characters before calling Grape::Json::dump.

@dm1try dm1try merged commit b464087 into ruby-grape:master Jan 11, 2022
@bschmeck bschmeck deleted the non-utf-8-format branch January 11, 2022 17:41
@bschmeck
Copy link
Contributor Author

Thanks for the quick merge, and all of your work on Grape!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants