wmorgan / heliotrope

A personal, threaded, search-centric email server.
124 stars 17 forks source link

JSON::GeneratorError: partial character in source, but hit end #9

Closed gebner closed 13 years ago

gebner commented 13 years ago

With ruby 1.8, snippets can sometimes end in the middle of a UTF-8 character, e.g. (note the "\303" at the end):

:snippet=>"Um die e-Mail vollst\303\244ndig sehen zu k\303\266nnen, muss HTML in Ihrem e-Mail Client aktiviert sein. Sie k\303"

This causes to_json to fail, and in turn heliotrope to return error messages:

irb(main):075:0> res.to_json
JSON::GeneratorError: partial character in source, but hit end
        from (irb):75:in `to_json'
        from (irb):75
        from bin/heliotrope-console:69

The patch removes the last (possibly incomplete) non-ASCII character from the snippet (in Message.snippet) if heliotrope is running on 1.8.