mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-11 04:51:15 -04:00
Limit join result length to 10240
This commit is contained in:
parent
ebe06a97d9
commit
48ae666458
2 changed files with 15 additions and 1 deletions
|
@ -91,7 +91,9 @@ class Scratch3OperatorsBlocks {
|
|||
}
|
||||
|
||||
join (args) {
|
||||
return Cast.toString(args.STRING1) + Cast.toString(args.STRING2);
|
||||
// Limit result to 10240 characters: https://github.com/LLK/scratch-vm/issues/922
|
||||
return (Cast.toString(args.STRING1) + Cast.toString(args.STRING2))
|
||||
.slice(0, 10240);
|
||||
}
|
||||
|
||||
letterOf (args) {
|
||||
|
|
|
@ -122,6 +122,18 @@ test('random - reverse', t => {
|
|||
test('join', t => {
|
||||
t.strictEqual(blocks.join({STRING1: 'foo', STRING2: 'bar'}), 'foobar');
|
||||
t.strictEqual(blocks.join({STRING1: '1', STRING2: '2'}), '12');
|
||||
t.strictEqual(blocks.join({STRING1: '1', STRING2: '2'}), '12');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('join result length does not exceed 10240', t => {
|
||||
const sixThousandCharacterString = Array(6000)
|
||||
.fill('a')
|
||||
.join('');
|
||||
t.strictEqual(blocks.join({
|
||||
STRING1: sixThousandCharacterString,
|
||||
STRING2: sixThousandCharacterString
|
||||
}).length, 10240);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue