Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs/node#3111 - v8BreakIterator disablement #4253

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ function setupConfig(_source) {
if (value === 'false') return false;
return value;
});
const processConfig = process.binding('config');
// Intl.v8BreakIterator() would crash w/ fatal error, so throw instead.
if (processConfig.hasIntl &&
processConfig.hasSmallICU &&
Intl.hasOwnProperty('v8BreakIterator') &&
!process.icu_data_dir) {
const des = Object.getOwnPropertyDescriptor(Intl, 'v8BreakIterator');
des.value = function v8BreakIterator() {
throw new Error('v8BreakIterator: full ICU data not installed. ' +
'See https://github.com/nodejs/node/wiki/Intl');
};
Object.defineProperty(Intl, 'v8BreakIterator', des);
}
// Don’t let icu_data_dir leak through.
delete process.icu_data_dir;
}


Expand Down
7 changes: 7 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,13 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(versions,
"icu",
OneByteString(env->isolate(), U_ICU_VERSION));

if (icu_data_dir != nullptr) {
// Did the user attempt (via env var or parameter) to set an ICU path?
READONLY_PROPERTY(process,
"icu_data_dir",
OneByteString(env->isolate(), icu_data_dir));
}
#endif

const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION);
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-intl-v8BreakIterator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
require('../common');
const assert = require('assert');

if (global.Intl === undefined || Intl.v8BreakIterator === undefined) {
return console.log('1..0 # Skipped: no Intl');
}

try {
new Intl.v8BreakIterator();
// May succeed if data is available - OK
} catch (e) {
// May throw this error if ICU data is not available - OK
assert.throws(() => new Intl.v8BreakIterator(), /ICU data/);
}