本文整理汇总了TypeScript中tinymce/core/html/SaxParser.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
suite.test('Parsing cdata', function () {
let counter, parser;
counter = createCounter(writer);
parser = new SaxParser(counter, schema);
writer.reset();
parser.parse('<![CDATA[test text]]>');
LegacyUnit.equal(writer.getContent(), '<![CDATA[test text]]>', 'Parse cdata with value.');
LegacyUnit.deepEqual(counter.counts, { cdata: 1 }, 'Parse cdata with value counts.');
counter = createCounter(writer);
parser = new SaxParser(counter, schema);
writer.reset();
parser.parse('<![CDATA[]]>');
LegacyUnit.equal(writer.getContent(), '', 'Parse cdata without value.');
LegacyUnit.deepEqual(counter.counts, {}, 'Parse cdata without value counts.');
counter = createCounter(writer);
parser = new SaxParser(counter, schema);
writer.reset();
parser.parse('<![CDATA[<b>a</b>]]>');
LegacyUnit.equal(writer.getContent(), '<![CDATA[<b>a</b>]]>', 'Parse cdata with tag inside.');
LegacyUnit.deepEqual(counter.counts, { cdata: 1 }, 'Parse cdata with tag inside counts.');
counter = createCounter(writer);
parser = new SaxParser(counter, schema);
writer.reset();
parser.parse('<b>a<![CDATA[value]]>b</b>');
LegacyUnit.equal(writer.getContent(), '<b>a<![CDATA[value]]>b</b>', 'Parse cdata with tags around it.');
LegacyUnit.deepEqual(counter.counts, { cdata: 1, start: 1, end: 1, text: 2 }, 'Parse cdata with tags around it counts.');
});
示例2: urls
suite.test('Parse script urls (denied)', function () {
let counter, parser;
counter = createCounter(writer);
counter.validate = false;
parser = new SaxParser(counter, schema);
writer.reset();
parser.parse(
'<a href="jAvaScript:alert(1)">1</a>' +
'<a href="vbscript:alert(2)">2</a>' +
'<a href="java\u0000script:alert(3)">3</a>' +
'<a href="\njavascript:alert(4)">4</a>' +
'<a href="java\nscript:alert(5)">5</a>' +
'<a href="java\tscript:alert(6)">6</a>' +
'<a href="%6aavascript:alert(7)">7</a>' +
'<a href="data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+">8</a>' +
'<a href=" dAt%61: tExt/html ; bAse64 , PHN2Zy9vbmxvYWQ9YWxlcnQoMik+">9</a>' +
'<object data="data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+">10</object>' +
'<button formaction="javascript:alert(11)">11</button>' +
'<table background="javascript:alert(12)"><tr><tr>12</tr></tr></table>' +
'<a href="mhtml:13">13</a>' +
'<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">' +
'<a href="%E3%82%AA%E3%83%BC%E3%83">Invalid url</a>'
);
LegacyUnit.equal(
writer.getContent(),
'<a>1</a><a>2</a><a>3</a><a>4</a><a>5</a><a>6</a><a>7</a><a>8</a><a>9</a>' +
'<object>10</object><button>11</button><table><tr></tr><tr>12</tr></table><a>13</a>' +
'<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />' +
'<a href="%E3%82%AA%E3%83%BC%E3%83">Invalid url</a>'
);
});