Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Prefer conversion to Buffer in application layer for data filter
Browse files Browse the repository at this point in the history
  • Loading branch information
diego-G committed Nov 6, 2018
1 parent c0dab65 commit 90e2f81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
4 changes: 2 additions & 2 deletions modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ __private.list = function(filter, cb) {

// Removing null characters from data filter to avoid errors in pg-promise library
if (filter.data) {
filter.data = filter.data.replace(/\0/g, '');
filter.data = Buffer.from(filter.data);
}

const allowedFieldsMap = {
Expand All @@ -128,7 +128,7 @@ __private.list = function(filter, cb) {
type: '"t_type" = ${type}',
minConfirmations: 'confirmations >= ${minConfirmations}',
data:
't_id IN (SELECT transfer."transactionId" FROM transfer WHERE transfer.data LIKE ${data}::bytea)',
't_id IN (SELECT transfer."transactionId" FROM transfer WHERE transfer.data LIKE ${data})',
limit: null,
offset: null,
sort: null,
Expand Down
28 changes: 1 addition & 27 deletions test/functional/http/get/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,32 +706,6 @@ describe('GET /api/transactions', () => {
});
});

it('using unicode null character with regex should return all the transactions', () => {
var dataFilter = '%\u0000%';
var count;
return transactionsEndpoint
.makeRequest(
{
data: '%',
},
200
)
.then(res => {
count = res.body.meta.count;
})
.then(() => {
return transactionsEndpoint.makeRequest(
{
data: dataFilter,
},
200
);
})
.then(res => {
expect(res.body.meta.count).to.equal(count);
});
});

it('using unicode character should return transactions', () => {
var unicodeCharacter = '฿';
var fuzzyCommand = '%';
Expand All @@ -743,7 +717,7 @@ describe('GET /api/transactions', () => {
200
)
.then(res => {
expect(res.body.data.length).to.greaterThan(1);
expect(res.body.data.length).to.greaterThan(0);
_.map(res.body.data, transaction => {
return expect(transaction.asset.data).to.include(
unicodeCharacter
Expand Down

0 comments on commit 90e2f81

Please sign in to comment.