Skip to content

events: prefix events to prevent breaking on known object properties #728

Description

@3rd-Eden

In the EventEmitter the events are stored in an plain Object instance. The event names that you use are added directly as property on the object so when you event names such as __proto__ it will break. One solution is to prefix the keys with a char such as ~.

Example case:

var EventEmitter = require('events').EventEmitter;
var e = new EventEmitter();

e.on('__proto__', function (bar) {
  console.log('foo', bar);
});
e.emit('__proto__', 1);

Willing to create pull request if bug requires fixing ;)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.eventsIssues and PRs related to EventEmitter and the events module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions