Skip to content

Commit 13bc899

Browse files
committed
Return FluentNone from Patterns with too long placeables
1 parent ae0c97d commit 13bc899

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

fluent/src/resolver.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,12 @@ export function resolveComplexPattern(scope, ptn) {
289289
`(${part.length}, max allowed is ${MAX_PLACEABLE_LENGTH})`
290290
)
291291
);
292-
result.push(part.slice(MAX_PLACEABLE_LENGTH));
293-
} else {
294-
result.push(part);
292+
scope.dirty.delete(ptn);
293+
return new FluentNone();
295294
}
296295

296+
result.push(part);
297+
297298
if (useIsolating) {
298299
result.push(PDI);
299300
}

fluent/test/bomb_test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ suite('Reference bombs', function() {
1313
});
1414

1515
suite('Billion Laughs', function(){
16+
this.timeout(10000);
17+
1618
suiteSetup(function() {
1719
bundle = new FluentBundle('en-US', { useIsolating: false });
1820
bundle.addMessages(ftl`
@@ -30,13 +32,14 @@ suite('Reference bombs', function() {
3032
`);
3133
});
3234

33-
// XXX Protect the FTL Resolver against the billion laughs attack
34-
// https://bugzil.la/1307126
35-
test.skip('does not expand all placeables', function() {
35+
test('does not expand all placeables', function() {
3636
const msg = bundle.getMessage('lolz');
3737
const val = bundle.formatPattern(msg.value, args, errs);
38-
assert.strictEqual(val, '???');
39-
assert.strictEqual(errs.length, 1);
38+
assert.strictEqual(
39+
val,
40+
'{???} {???} {???} {???} {???} {???} {???} {???} {???} {???}'
41+
);
42+
assert.strictEqual(errs.length, 10010);
4043
});
4144
});
4245
});

0 commit comments

Comments
 (0)