Strubbl / wallabago

Go wrapper for the Wallabag API
GNU General Public License v3.0
11 stars 5 forks source link

strip unicode BOM characters from config #6

Closed anarcat closed 7 years ago

anarcat commented 7 years ago

i encountered such a situation when field-testing wallabako: the user would copy the config snippet from the website, paste it into her prefered text editor (LibreOffice) and save it as a .txt file. LibreOffice then inserts a BOM character at the beginning of the file even though that is forbidden by the JSON spec.

then the JSON parser crashes with this weird error:

invalid character 'ï' looking for beginning of value

which makes the file unparseable. there is little the user can do to recover: the unicode magic character is completely invisible and most editors (vim, emacs) don't remove it. i had to copy-paste in a terminal (because in the editor the character is kept on copy-paste too) to actually remote the nasty stuff.

so play it safe and just cleanup config files we find. this doesn't hurt performance and is weird, but golang people refuse to fix this.

Strubbl commented 7 years ago

Oh, ok. Good catch. Thanks for the PR