mirror of https://github.com/zulip/zulip.git
node tests: Add tests for escaped attributes in vdom.
This commit is contained in:
parent
4fbcbeeea7
commit
d536e9f27b
|
@ -22,7 +22,31 @@ run_test('basics', () => {
|
|||
);
|
||||
});
|
||||
|
||||
run_test('attributes', () => {
|
||||
run_test('attribute escaping', () => {
|
||||
// So far most of the time our attributes are
|
||||
// hard-coded classes like "expanded_private_messages",
|
||||
// but we need to be defensive about future code
|
||||
// that might use data from possibly malicious users.
|
||||
const opts = {
|
||||
keyed_nodes: [],
|
||||
attrs: [
|
||||
['class', '">something evil<div class="'],
|
||||
['title', 'apples & oranges'],
|
||||
],
|
||||
};
|
||||
|
||||
const ul = vdom.ul(opts);
|
||||
|
||||
const html = vdom.render_tag(ul);
|
||||
|
||||
assert.equal(
|
||||
html,
|
||||
'<ul class="">something evil<div class="" ' +
|
||||
'title="apples & oranges">\n\n</ul>'
|
||||
);
|
||||
});
|
||||
|
||||
run_test('attribute updates', () => {
|
||||
const opts = {
|
||||
keyed_nodes: [],
|
||||
attrs: [
|
||||
|
|
Loading…
Reference in New Issue