Loading ...
Sorry, an error occurred while loading the content.

59ADsafe, Take 3

Expand Messages
  • Douglas Crockford
    Oct 3, 2007
    • 0 Attachment
      This is the definition of ADSAFE.get and ADSAFE.set.

      var ADSAFE = function () {
      var exclude = {
      apply : true,
      begetObject : true,
      call : true,
      callee : true,
      caller : true,
      clone : true,
      constructor : true,
      'eval' : true,
      'new' : true,
      prototype : true,
      source : true,
      'this' : true,
      toSource : true,
      toString : true,
      watch : true
      };

      var reject = function check(object, name) {
      return !object || !name || typeof object === 'function' ||
      typeof name !== 'string' || exclude[name] ||
      name.charAt[0] === '_' || name.indexOf('$') >= 0;
      };

      return {
      get: function (object, name) {
      var value;
      if (reject(object, name)) {
      return;
      }
      value = object[name];
      if (typeof value === 'function') {
      return;
      }
      return value;
      },
      set: function (object, name, value) {
      if (reject(object, name) || typeof value === 'function') {
      return;
      }
      object[name] = value;
      return object;
      }
      };
      }();

      Are there any weakness in .get and .set that would allow a program
      that passed JSLint/ADsafe to alert?
    • Show all 17 messages in this topic