remove Intl entirely, for now
MODIFY
src/bundle/createSES.js
src/bundle/createSES.js
@@ -38,9 +38,23 @@ export function createSESWithRealmConstructor(creatorStrings, Realm) {
shims.push(`(${tameMath})();`);
}
+ // Intl is disabled entirely for now, deleted by removeProperties. If we
+ // want to bring it back (under the control of this option), we'll need
+ // to add it to the whitelist too, as well as taming it properly.
if (options.intlMode !== "allow") {
+ // this shim also disables Object.prototype.toLocaleString
shims.push(`(${tameIntl})();`);
+ } else {
+ /*
+ wl.Intl = {
+ Collator: true,
+ DateTimeFormat: true,
+ NumberFormat: true,
+ PluralRules: true,
+ getCanonicalLocales: true
}
+ */
+ };
if (options.errorStackMode !== "allow") {
shims.push(`(${tameError})();`);

MODIFY
test/test-intl.js
test/test-intl.js
import test from 'tape';
import SES from '../src/index.js';
-test('Intl neutered by default', function(t) {
+// Intl is removed entirely and unconditionally, for now. We might bring this
+// back in the future.
+
+test('Intl removed by default', function(t) {
const s = SES.makeSESRootRealm();
- t.throws(() => s.evaluate('Intl.DateTimeFormat()'), Error);
- t.throws(() => s.evaluate('Intl.NumberFormat()'), Error);
- t.throws(() => s.evaluate('Intl.getCanonicalLocales()'), Error);
+ t.equal(s.evaluate('typeof Intl'), 'undefined');
t.throws(() => s.evaluate('({}).toLocaleString()'), Error);
t.end();
});
-test('Math.random neutered upon request', function(t) {
- const s = SES.makeSESRootRealm({mathRandomMode: false});
+/*
+test('Intl neutered by default', function(t) {
+ const s = SES.makeSESRootRealm();
t.throws(() => s.evaluate('Intl.DateTimeFormat()'), Error);
t.throws(() => s.evaluate('Intl.NumberFormat()'), Error);
t.throws(() => s.evaluate('Intl.getCanonicalLocales()'), Error);
@@ -20,7 +22,7 @@ test('Math.random neutered upon request', function(t) {
});
test('Intl can be left alone', function(t) {
- const s = SES.makeSESRootRealm({intlMode: "allow"});
+ const s = SES.makeSESRootRealm({intlMode: "allow", errorStackMode: "allow"});
// All we test is that these don't throw exceptions. The exact output will
// depend upon the locale in which we run the tests.
s.evaluate('Intl.DateTimeFormat().format(1234)');
@@ -29,3 +31,4 @@ test('Intl can be left alone', function(t) {
s.evaluate('({}).toLocaleString()');
t.end();
});
+*/

remove Intl entirely, for now