New issue
Advanced search Search tips

Issue 807769 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 2
Type: Bug

Blocked on:
issue 807771



Sign in to add a comment

i18n.getMessage behaves weirdly in edge cases

Project Member Reported by rdevlin....@chromium.org, Jan 31 2018

Issue description

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.
 
Blockedon: 807771
Components: Platform>Extensions

Sign in to add a comment