OP-01-011 Error suppression in UTF-8 decoding function (Medium). Add check for parameter type to decode_utf8.
This commit is contained in:
parent
3f626f4bfb
commit
28e7a80eba
|
@ -142,6 +142,9 @@ module.exports = {
|
|||
* @return {String} A native javascript string
|
||||
*/
|
||||
decode_utf8: function (utf8) {
|
||||
if (typeof utf8 !== 'string') {
|
||||
throw new Error('Parameter "utf8" is not of type string');
|
||||
}
|
||||
try {
|
||||
return decodeURIComponent(escape(utf8));
|
||||
} catch (e) {
|
||||
|
|
|
@ -328,4 +328,13 @@ describe('Basic', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Misc.", function() {
|
||||
|
||||
it('util.decode_utf8 throws error if invalid parameter type', function () {
|
||||
var test = openpgp.util.decode_utf8.bind(null, {chameleon: true});
|
||||
expect(test).to.throw(Error, /Parameter "utf8" is not of type string/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user