diff --git a/src/http-api/resources/config.js b/src/http-api/resources/config.js index 869c2bfc80..214fdeb459 100644 --- a/src/http-api/resources/config.js +++ b/src/http-api/resources/config.js @@ -58,6 +58,13 @@ exports.getOrSet = { const key = request.pre.args.key const value = request.pre.args.value + if (typeof value === 'object' && value.type === 'Buffer') { + return reply({ + Message: 'Invalid value type', + Code: 0 + }).code(500) + } + if (value === undefined) { // Get the value of a given key return request.server.app.ipfs.config.get((err, config) => { diff --git a/test/http-api/interface-ipfs-core-over-ipfs-api/test-config.js b/test/http-api/interface-ipfs-core-over-ipfs-api/test-config.js index e69de29bb2..fe8cbbb667 100644 --- a/test/http-api/interface-ipfs-core-over-ipfs-api/test-config.js +++ b/test/http-api/interface-ipfs-core-over-ipfs-api/test-config.js @@ -0,0 +1,20 @@ +/* eslint-env mocha */ + +'use strict' + +const test = require('interface-ipfs-core') +const FactoryClient = require('./../../utils/factory-http') + +let fc + +const common = { + setup: function (callback) { + fc = new FactoryClient() + callback(null, fc) + }, + teardown: function (callback) { + fc.dismantle(callback) + } +} + +test.config(common)