The i18n.getMessage API takes in an optional argument for substitutions, which can either be a single value or an array of values. If passed in non-string values in the array, the bindings will attempt to coerce a string out of the value. If passed a non-string value as a single parameter, it is silently ignored. If a value throws in conversion, the failure is silently caught and the value is silently ignored.
So given a message with a name 'm' and a value 'placeholder: $1':
getMessage('m', 'something') -> 'placeholder: something' // sane
getMessage('m', ['something]') -> 'placeholder: something' // sane
getMessage('m', {}) -> 'placeholder: $1' // ?
getMessage('m', [{}] -> 'placeholder: [object Object]' // ?
getMessage('m', {toString: function() { throw new Error(); }}) ->
'placeholder: $1' // ?
getMessage('m', [{toString: function() { throw new Error(); }}, 'something']) ->
'placeholder: something'** // ?
** See also blocking bug.
We should really make this all more cohesive. My guess is that these should have just been accepting string values, but I wonder if there are any extensions relying on the implicit conversion.
Comment 1 by rdevlin....@chromium.org
, Jan 31 2018Components: Platform>Extensions