spyne 0.20.8 → 0.20.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/spyne.esm.js +2 -2
- package/lib/spyne.esm.js.map +1 -1
- package/lib/spyne.umd.js +2 -2
- package/lib/spyne.umd.js.LICENSE.txt +2 -2
- package/package.json +1 -1
- package/src/spyne/spyne-app.js +2 -2
- package/src/spyne/views/dom-element-template.js +1 -0
- package/src/tests/views/dom-el-template.test.js +72 -0
package/package.json
CHANGED
package/src/spyne/spyne-app.js
CHANGED
|
@@ -5,7 +5,7 @@ import { SpyneAppProperties } from './utils/spyne-app-properties.js'
|
|
|
5
5
|
import { sanitizeHTMLConfigure } from './utils/sanitize-html.js'
|
|
6
6
|
|
|
7
7
|
const _channels = new ChannelsMap()
|
|
8
|
-
const version = '0.20.
|
|
8
|
+
const version = '0.20.9'
|
|
9
9
|
|
|
10
10
|
class SpyneApplication {
|
|
11
11
|
/**
|
|
@@ -42,7 +42,7 @@ class SpyneApplication {
|
|
|
42
42
|
init(config = {}, testMode = false) {
|
|
43
43
|
// this.channels = new ChannelsMap();
|
|
44
44
|
/*!
|
|
45
|
-
* Spyne 0.20.
|
|
45
|
+
* Spyne 0.20.9
|
|
46
46
|
* https://spynejs.org
|
|
47
47
|
*
|
|
48
48
|
* @license
|
|
@@ -3,6 +3,78 @@ import { ScriptTemplate, StringTemplate, starWarsData } from '../mocks/template-
|
|
|
3
3
|
import { DomElement } from '../../spyne/views/dom-element'
|
|
4
4
|
|
|
5
5
|
chai.use(require('chai-dom'))
|
|
6
|
+
describe('DomElementTemplate should safely render special strings', () => {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const testCases = [
|
|
11
|
+
{
|
|
12
|
+
ref: 'dollarDigit',
|
|
13
|
+
label: 'should properly add $ sign before a number',
|
|
14
|
+
val: 'Currently raising $1.5M'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
ref: 'dollarAmp',
|
|
18
|
+
label: 'should preserve $& which refers to full match in replace',
|
|
19
|
+
val: 'Matched value was: $&'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
ref: 'dollarBacktick',
|
|
23
|
+
label: 'should preserve $` which refers to text before match in replace',
|
|
24
|
+
val: 'Before the match: $`'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
ref: 'dollarSingleQuote',
|
|
28
|
+
label: 'should preserve $\' which refers to text after match in replace',
|
|
29
|
+
val: "After the match: $\'"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
ref: 'backslashPath',
|
|
33
|
+
label: 'should preserve file path backslashes',
|
|
34
|
+
val: 'User path: C:\\Users\\Frank\\Documents'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
ref: 'curlyBraces',
|
|
38
|
+
label: 'should preserve double curly brace templates in string',
|
|
39
|
+
val: 'This is not a template: {{user.name}}'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
ref: 'scriptTag',
|
|
43
|
+
label: 'should render inline script tags safely (if allowed)',
|
|
44
|
+
val: 'Click here: <script>alert("XSS")</script>'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
ref: 'richContentWithDot',
|
|
48
|
+
label: 'should allow rich content with template syntax inside',
|
|
49
|
+
val: 'Hello <b>{{.}}</b>, welcome back.'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
ref: 'unicodeCurrency',
|
|
53
|
+
label: 'should preserve Unicode and currency characters',
|
|
54
|
+
val: 'Price is €100 or ¥12000'
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
testCases.forEach(({ label, val, ref }) => {
|
|
59
|
+
it(`${ref}: ${label}`, () => {
|
|
60
|
+
const data = { val, arr: [val] };
|
|
61
|
+
|
|
62
|
+
const template = '<h1>I am {{val}}'
|
|
63
|
+
const domElTmpl = new DomElementTemplate(template, data, { testMode: true });
|
|
64
|
+
const render = domElTmpl.renderDocFrag();
|
|
65
|
+
|
|
66
|
+
const templateArr = '<h1>{{#arr}}{{.*}}{{/arr}}</h1>'
|
|
67
|
+
const domElTmpArr = new DomElementTemplate(templateArr, data, { testMode: true });
|
|
68
|
+
const renderArr = domElTmpArr.renderDocFrag();
|
|
69
|
+
|
|
70
|
+
//console.log("RENDER: ", render.firstElementChild.innerText," RENDERARR: ", renderArr.firstElementChild.innerText);
|
|
71
|
+
|
|
72
|
+
expect(render.firstElementChild.innerHTML).to.include(val.replace(/\n/g, ''));
|
|
73
|
+
expect(renderArr.firstElementChild.innerHTML).to.include(val.replace(/\n/g, ''));
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
|
6
78
|
|
|
7
79
|
describe('DomElTemplate', () => {
|
|
8
80
|
it('template renderer exists', () => {
|