chrisdanford / grunt-ver

MIT License
19 stars 15 forks source link

Proper use of encoding for hashing international characters. #7

Open michaellopez opened 11 years ago

michaellopez commented 11 years ago

The documentation for hash.update() states that if no encoding is given, the argument is expected to be a Buffer.

Like many other "hash tasks" for Grunt, grunt-ver provides the contents of the file as a string to hash.update without any encoding as a second argument, which is incorrect.

The result of this is an incorrect hash for files with international characters in them when no encoding is given to hash.update.

Setting the proper encoding when calling hash.update fixes this.

PS. This plugin could use a bit of refactoring to allow passing options and such. My PR only handles the encoding bit though.