Closed StarpTech closed 7 years ago
@mcollina
How to reproduce
'use strict'; const Bloomrun = require('bloomrun'); let catalog = Bloomrun() for (var index = 0; index < 100; index++) { let pattern = { topic: 'math', cmd: 'add' + index }; let value = catalog.lookup(pattern); if (value) { console.log(pattern) throw "Already registered!" } catalog.add(pattern, index); }
The bug is in safeEqual
safeEqual
console.log(safeEqual('add1', 'add10')) // true
You don't iterate the longest string. add1 is equals with add10 because the character add1[1,3] is equals to add10[1,3]
add1
add10
https://github.com/mcollina/bloomrun/blob/master/lib/safeEqual.js#L10
I create a PR https://github.com/mcollina/bloomrun/pull/47
@mcollina In which case we can't use a ''===' ?
This is it https://github.com/mcollina/bloomrun/issues/30
@mcollina
How to reproduce
The bug is in
safeEqual
You don't iterate the longest string.
add1
is equals withadd10
because the character add1[1,3] is equals to add10[1,3]https://github.com/mcollina/bloomrun/blob/master/lib/safeEqual.js#L10