Skip to content

Commit 276a3c0

Browse files
committed
MBS-13496: Support attributes with spaces in link phrase interpolation
Using the new "a cappella" attribute was breaking link phrase interpolation, because spaces were not accepted as part of the interpolated "variable name". We already had several attributes with spaces in their name though, we just had gotten lucky we were not using any of them in link phrases until now. Just adding spaces to the allowed characters doesn't seem to cause any new issues, so it seems good enough for our needs.
1 parent 1873cac commit 276a3c0

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

root/static/scripts/common/i18n/expand2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export const createTextContentParser = <T, V>(
206206
return mapValue(text);
207207
};
208208

209-
const varSubst = /^\{([0-9A-z_]+)\}/;
209+
const varSubst = /^\{([0-9A-z_ ]+)\}/;
210210
export const createVarSubstParser = <T, V>(
211211
argFilter: (V) => T,
212212
): Parser<T | string | NO_MATCH, V> => saveMatch(
@@ -225,7 +225,7 @@ export const createVarSubstParser = <T, V>(
225225
export const parseStringVarSubst: Parser<string | NO_MATCH, mixed> =
226226
createVarSubstParser<string, mixed>(getString);
227227

228-
const condSubstStart = /^\{([0-9A-z_]+):/;
228+
const condSubstStart = /^\{([0-9A-z_ ]+):/;
229229
const verticalPipe = /^\|/;
230230
export const substEnd: RegExp = /^}/;
231231
export const createCondSubstParser = <T, V: Expand2ReactInput>(

root/static/scripts/common/i18n/expand2react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type Output = Expand2ReactOutput;
5353
const textContent = /^[^<>{}]+/;
5454
const condSubstThenTextContent = /^[^<>{}|]+/;
5555
const percentSign = /(%)/;
56-
const linkSubstStart = /^\{([0-9A-z_]+)\|/;
56+
const linkSubstStart = /^\{([0-9A-z_ ]+)\|/;
5757
const htmlTagStart = /^<(?=[a-z])/;
5858
const htmlTagName = /^(a|abbr|br|code|em|h1|h2|h3|h4|h5|h6|hr|li|ol|p|span|strong|ul)(?=[\s\/>])/;
5959
const htmlTagEnd = /^>/;

root/static/scripts/tests/i18n/expand2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import expand2text, {
1111
} from '../../common/i18n/expand2text.js';
1212

1313
test('expand2', function (t) {
14-
t.plan(69);
14+
t.plan(70);
1515

1616
let error = '';
1717
const consoleError = console.error;
@@ -46,6 +46,7 @@ test('expand2', function (t) {
4646
);
4747
expandText('An {apple_fruit}', null, 'An {apple_fruit}');
4848
expandText('An {apple_fruit}', {apple_fruit: 'apple'}, 'An apple');
49+
expandText('An {apple fruit}', {'apple fruit': 'apple'}, 'An apple');
4950
expandText('A {number}', {number: 1}, 'A 1');
5051
expandHtml('{null} value', {null: null}, ' value');
5152
t.equal(error, '');

0 commit comments

Comments
 (0)