mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix: sanitize object keys in evaluation result parsing (#35947)
This commit is contained in:
parent
191d912f20
commit
e356ec0a82
@ -156,8 +156,11 @@ export function parseEvaluationResultValue(value: SerializedValue, handles: any[
|
||||
if ('o' in value) {
|
||||
const result: any = {};
|
||||
refs.set(value.id, result);
|
||||
for (const { k, v } of value.o)
|
||||
for (const { k, v } of value.o) {
|
||||
if (k === '__proto__')
|
||||
continue;
|
||||
result[k] = parseEvaluationResultValue(v, handles, refs);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if ('h' in value)
|
||||
|
||||
@ -881,3 +881,12 @@ it('should work with deleted Map', {
|
||||
await page.goto(server.PREFIX + '/page');
|
||||
expect(await page.evaluate(x => ({ value: 2 * x }), 17)).toEqual({ value: 34 });
|
||||
});
|
||||
|
||||
it('should ignore dangerous object keys', async ({ page }) => {
|
||||
const input = {
|
||||
__proto__: { polluted: true },
|
||||
safeKey: 'safeValue'
|
||||
};
|
||||
const result = await page.evaluate(arg => arg, input);
|
||||
expect(result).toEqual({ safeKey: 'safeValue' });
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user