mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-07 20:08:54 -04:00
Fix issue where non-strings were getting passed in to escape functions for handling special characters that can appear in xml. Add tests.
This commit is contained in:
parent
765f2b2549
commit
c761a9c82e
4 changed files with 88 additions and 2 deletions
test/unit
|
@ -109,3 +109,21 @@ test('replaceUnsafeChars', t => {
|
|||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('replaceUnsafeChars should handle non strings', t => {
|
||||
const array = ['hello', 'world'];
|
||||
t.equal(StringUtil.replaceUnsafeChars(array), String(array));
|
||||
|
||||
const arrayWithSpecialChar = ['hello', '<world>'];
|
||||
t.equal(StringUtil.replaceUnsafeChars(arrayWithSpecialChar), 'hello,ltworldgt');
|
||||
|
||||
const arrayWithNumbers = [1, 2, 3];
|
||||
t.equal(StringUtil.replaceUnsafeChars(arrayWithNumbers), '1,2,3');
|
||||
|
||||
// Objects shouldn't get provided to replaceUnsafeChars, but in the event
|
||||
// they do, it should just return the object (and log an error)
|
||||
const object = {hello: 'world'};
|
||||
t.equal(StringUtil.replaceUnsafeChars(object), object);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue