Skip to content

Commit 8ccf3e8

Browse files
committed
add test for invalid namespace declarations
1 parent f3a1352 commit 8ccf3e8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

test/fixtures/reserved-namespace.svg

Lines changed: 4 additions & 0 deletions
Loading

test/fixup-svg-string.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ test('fixupSvgString should make parsing fixtures not throw', t => {
2828
t.end();
2929
});
3030

31+
test('fixupSvgString should correct namespace declarations bound to reserved namespace names', t => {
32+
const filePath = path.resolve(__dirname, './fixtures/reserved-namespace.svg');
33+
const svgString = fs.readFileSync(filePath)
34+
.toString();
35+
const fixed = fixupSvgString(svgString);
36+
37+
// Make sure undefineds aren't being written into the file
38+
t.equal(fixed.indexOf('undefined'), -1);
39+
t.notThrow(() => {
40+
domParser.parseFromString(fixed, 'text/xml');
41+
});
42+
t.end();
43+
});
44+
3145
test('fixupSvgString should prevent script tags', t => {
3246
const filePath = path.resolve(__dirname, './fixtures/script.svg');
3347
const svgString = fs.readFileSync(filePath)

0 commit comments

Comments
 (0)