Skip to content

Support extended Object.prototypes #534

Closed
@mathiasbynens

Description

@mathiasbynens

This works fine:

var template = Handlebars.compile('{{foo}}');
template({ foo: 'bar' });
// 'bar'

This breaks:

Object.prototype[0xD834] = true;
var template = Handlebars.compile('{{foo}}');
template({ foo: 'bar' });
// throws error

This led to a very obscure bug in Istanbul: gotwarlost/istanbul#55

I haven’t looked into this yet, but it seems like the sort of bug that can be avoided by simply using hasOwnProperty checks.

Update: It may have something to do with this line: https://github.com/wycats/handlebars.js/blob/6bf9c6fc134c87dc150e485ea018c4b3f108e6b0/lib/handlebars/compiler/compiler.js#L568 params is an array, so it gets the 55348 property, which gets enumerated somewhere else, I guess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions