| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 27c17ce commit 5966650
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,21 @@ function setupConfig(_source) { | |||
| 117 | 117 | if (value === 'false') return false; | |
| 118 | 118 | return value; | |
| 119 | 119 | }); | |
| 120 | + const processConfig = process.binding('config'); | ||
| 121 | + // Intl.v8BreakIterator() would crash w/ fatal error, so throw instead. | ||
| 122 | + if (processConfig.hasIntl && | ||
| 123 | + processConfig.hasSmallICU && | ||
| 124 | + Intl.hasOwnProperty('v8BreakIterator') && | ||
| 125 | + !process.icu_data_dir) { | ||
| 126 | + const des = Object.getOwnPropertyDescriptor(Intl, 'v8BreakIterator'); | ||
| 127 | + des.value = function v8BreakIterator() { | ||
| 128 | + throw new Error('v8BreakIterator: full ICU data not installed. ' + | ||
| 129 | + 'See https://github.com/nodejs/node/wiki/Intl'); | ||
| 130 | + }; | ||
| 131 | + Object.defineProperty(Intl, 'v8BreakIterator', des); | ||
| 132 | + } | ||
| 133 | + // Don’t let icu_data_dir leak through. | ||
| 134 | + delete process.icu_data_dir; | ||
| 120 | 135 | } | |
| 121 | 136 | ||
| 122 | 137 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2976,6 +2976,13 @@ void SetupProcessObject(Environment* env, | |||
| 2976 | 2976 | READONLY_PROPERTY(versions, | |
| 2977 | 2977 | "icu", | |
| 2978 | 2978 | OneByteString(env->isolate(), U_ICU_VERSION)); | |
| 2979 | + | ||
| 2980 | + if (icu_data_dir != nullptr) { | ||
| 2981 | + // Did the user attempt (via env var or parameter) to set an ICU path? | ||
| 2982 | + READONLY_PROPERTY(process, | ||
| 2983 | + "icu_data_dir", | ||
| 2984 | + OneByteString(env->isolate(), icu_data_dir)); | ||
| 2985 | + } | ||
| 2979 | 2986 | #endif | |
| 2980 | 2987 | ||
| 2981 | 2988 | const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + | ||
| 5 | + if (global.Intl === undefined || Intl.v8BreakIterator === undefined) { | ||
| 6 | + return console.log('1..0 # Skipped: no Intl'); | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + try { | ||
| 10 | + new Intl.v8BreakIterator(); | ||
| 11 | + // May succeed if data is available - OK | ||
| 12 | + } catch (e) { | ||
| 13 | + // May throw this error if ICU data is not available - OK | ||
| 14 | + assert.throws(() => new Intl.v8BreakIterator(), /ICU data/); | ||
| 15 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments