Skip to content
This repository has been archived by the owner. It is now read-only.

Fix bug in regex parsing #174

Merged
merged 1 commit into from Feb 7, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Fix bug in regex parsing

Fix #173
  • Loading branch information
bbondy committed Feb 7, 2019
commit 9cd4b6583d480cc09b1418f71e7882ef7efcee9b
@@ -334,7 +334,7 @@ void parseFilter(const char *input, const char *end, Filter *f,
}
break;
case '/': {
const size_t inputLen = strlen(input);
const size_t inputLen = end - input;
if (parseState == FPStart || parseState == FPPastWhitespace) {
if (input[inputLen - 1] == '/' && inputLen > 1) {
// Just copy out the whole regex and return early
@@ -89,4 +89,32 @@ describe('parsing', function () {
})
})
})
describe('regex parsing', function () {
// See https://github.com/brave/ad-block/issues/173 for details
it('regex should not check last character of input buffer', function (cb) {
makeAdBlockClientFromString('/filter1\nfilter2/').then((client) => {
// regex are considered noFingerprintFilters
assert.equal(client.getFilters('filters').length, 2)
cb()
})
})
it('regex should not be a no fingerprint filter', function (cb) {
makeAdBlockClientFromString('/filter1/\nfilter2/').then((client) => {
// regex are considered noFingerprintFilters
assert.equal(client.getFilters('filters').length, 1)
assert.equal(client.getFilters('noFingerprintFilters').length, 1)
cb()
})
})
// See https://github.com/brave/ad-block/issues/173 for details
it('should serialize correctly', function (cb) {
makeAdBlockClientFromString('/filter1\nfilter2/\n').then((client) => {
makeAdBlockClientFromString('/filter1\nfilter2/').then((client2) => {
// regex are considered noFingerprintFilters
assert.equal(client.serialize().length, client2.serialize().length)
cb()
})
})
})
})
})
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.