Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions __tests__/normalize-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,25 @@ function normalizePathDict(paths: mixed): ?{[key: string]: mixed} {

return out;
}

describe('util DOS regression', () => {
const MAX_MS = 500;

test('dos1', () => {
const person = '' + '<'.repeat(100000) + '\u0000';
const start = Date.now();
const parsed = util.parsePerson(person);
const duration = Date.now() - start;
expect(parsed).toEqual({});
expect(duration).toBeLessThan(MAX_MS);
});

test('dos2', () => {
const person = '' + '('.repeat(100000) + '\u0000';
const start = Date.now();
const parsed = util.parsePerson(person);
const duration = Date.now() - start;
expect(parsed).toEqual({});
expect(duration).toBeLessThan(MAX_MS);
});
});
4 changes: 2 additions & 2 deletions src/util/normalize-manifest/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export function parsePerson(person: mixed): any {
}
}

const email = person.match(/<([^>]+)>/);
const email = person.match(/<([^<>]+)>/);
if (email) {
obj.email = email[1];
}

const url = person.match(/\(([^\)]+)\)/);
const url = person.match(/\(([^\(\)]+)\)/);
if (url) {
obj.url = url[1];
}
Expand Down