Skip to content

Commit 416f666

Browse files
committed
Check type of the value we extract from navigator.language before attempting string operation.
This is to work around a bug in the current webOS WebKit, but it doesn't hurt to be safe in any case. Enyo-DCO-1.1-Signed-off-by: Gray Norton <[email protected]>
1 parent 93f23ef commit 416f666

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

source/base/javascript/g11n.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ enyo.g11n._init = function _init(){
5555
/* Old browsers might not have a navigator object */
5656
if (navigator) {
5757
/* Everyone uses navigator.language, except for IE which uses navigator.userLanguage. Of course they do. */
58-
var locale = (navigator.language || navigator.userLanguage).replace(/-/g,'_').toLowerCase();
59-
enyo.g11n._locale = new enyo.g11n.Locale(locale);
60-
enyo.g11n._formatLocale = enyo.g11n._locale;
61-
enyo.g11n._phoneLocale = enyo.g11n._locale;
58+
var language = navigator.language || navigator.userLanguage;
59+
/* To be safe, make sure we have a string. */
60+
if ("string" === typeof language) {
61+
var locale = language.replace(/-/g,'_').toLowerCase();
62+
enyo.g11n._locale = new enyo.g11n.Locale(locale);
63+
enyo.g11n._formatLocale = enyo.g11n._locale;
64+
enyo.g11n._phoneLocale = enyo.g11n._locale;
65+
}
6266
}
6367

6468
if (enyo.g11n._locale === undefined) {

0 commit comments

Comments
 (0)