Browse Source

root-certs: use hasOwnProperty check instead of __proto__=null.

patch-2
Christopher Jeffrey 11 years ago
parent
commit
8a84092be9
  1. 8
      browser/root-certs
  2. 8
      lib/common/RootCerts.js

8
browser/root-certs

@ -34,8 +34,6 @@ function getRootCerts(callback) {
+ '"' + key + '":\n'; + '"' + key + '":\n';
}); });
body += '' body += ''
+ '\n'
+ 'certs.__proto__ = null;\n'
+ '\n' + '\n'
+ '// Use hash table for efficiency:\n' + '// Use hash table for efficiency:\n'
+ 'var trusted = Object.keys(certs).reduce(function(trusted, key) {\n' + 'var trusted = Object.keys(certs).reduce(function(trusted, key) {\n'
@ -45,20 +43,20 @@ function getRootCerts(callback) {
+ ' pem = pem.replace(/\\s+/g, "");\n' + ' pem = pem.replace(/\\s+/g, "");\n'
+ ' trusted[pem] = key;\n' + ' trusted[pem] = key;\n'
+ ' return trusted;\n' + ' return trusted;\n'
+ '}, { __proto__: null });\n' + '}, {});\n'
+ '\n' + '\n'
+ 'function getTrusted(pem) {\n' + 'function getTrusted(pem) {\n'
+ ' pem = pem + "";\n' + ' pem = pem + "";\n'
+ ' pem = pem.replace(/-----BEGIN CERTIFICATE-----/g, "");\n' + ' pem = pem.replace(/-----BEGIN CERTIFICATE-----/g, "");\n'
+ ' pem = pem.replace(/-----END CERTIFICATE-----/g, "");\n' + ' pem = pem.replace(/-----END CERTIFICATE-----/g, "");\n'
+ ' pem = pem.replace(/\\s+/g, "");\n' + ' pem = pem.replace(/\\s+/g, "");\n'
+ ' if (pem === "__proto__") return;\n' + ' if (!Object.prototype.hasOwnProperty.call(certs, pem)) return;\n'
+ ' return certs[pem];\n' + ' return certs[pem];\n'
+ '}\n' + '}\n'
+ '\n' + '\n'
+ 'function getCert(name) {\n' + 'function getCert(name) {\n'
+ ' name = name.replace(/^\s+|\s+$/g, "");\n' + ' name = name.replace(/^\s+|\s+$/g, "");\n'
+ ' if (name === "__proto__") return;\n' + ' if (!Object.prototype.hasOwnProperty.call(trusted, name)) return;\n'
+ ' return trusted[name];\n' + ' return trusted[name];\n'
+ '}\n' + '}\n'
+ '\n' + '\n'

8
lib/common/RootCerts.js

@ -3704,8 +3704,6 @@ var certs = {
+ "-----END CERTIFICATE-----\n" + "-----END CERTIFICATE-----\n"
}; };
certs.__proto__ = null;
// Use hash table for efficiency: // Use hash table for efficiency:
var trusted = Object.keys(certs).reduce(function(trusted, key) { var trusted = Object.keys(certs).reduce(function(trusted, key) {
var pem = certs[key]; var pem = certs[key];
@ -3714,20 +3712,20 @@ var trusted = Object.keys(certs).reduce(function(trusted, key) {
pem = pem.replace(/\s+/g, ""); pem = pem.replace(/\s+/g, "");
trusted[pem] = key; trusted[pem] = key;
return trusted; return trusted;
}, { __proto__: null }); }, {});
function getTrusted(pem) { function getTrusted(pem) {
pem = pem + ""; pem = pem + "";
pem = pem.replace(/-----BEGIN CERTIFICATE-----/g, ""); pem = pem.replace(/-----BEGIN CERTIFICATE-----/g, "");
pem = pem.replace(/-----END CERTIFICATE-----/g, ""); pem = pem.replace(/-----END CERTIFICATE-----/g, "");
pem = pem.replace(/\s+/g, ""); pem = pem.replace(/\s+/g, "");
if (pem === "__proto__") return; if (!Object.prototype.hasOwnProperty.call(certs, pem)) return;
return certs[pem]; return certs[pem];
} }
function getCert(name) { function getCert(name) {
name = name.replace(/^s+|s+$/g, ""); name = name.replace(/^s+|s+$/g, "");
if (name === "__proto__") return; if (!Object.prototype.hasOwnProperty.call(trusted, name)) return;
return trusted[name]; return trusted[name];
} }

Loading…
Cancel
Save