mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 08:33:43 +00:00
34 lines
1.6 KiB
JavaScript
34 lines
1.6 KiB
JavaScript
"use strict";
|
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
const {zrequire} = require("./lib/namespace");
|
|
const {run_test} = require("./lib/test");
|
|
|
|
const {postprocess_content} = zrequire("postprocess_content");
|
|
|
|
run_test("postprocess_content", () => {
|
|
assert.equal(
|
|
postprocess_content(
|
|
'<a href="http://example.com">good</a> ' +
|
|
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png">upload</a> ' +
|
|
'<a href="http://localhost:NNNN">invalid</a> ' +
|
|
'<a href="javascript:alert(1)">unsafe</a> ' +
|
|
'<a href="/#fragment" target="_blank">fragment</a>' +
|
|
'<div class="message_inline_image">' +
|
|
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.png" title="inline image">upload</a> ' +
|
|
'<a role="button">button</a> ' +
|
|
"</div>",
|
|
),
|
|
'<a href="http://example.com" target="_blank" rel="noopener noreferrer" title="http://example.com/">good</a> ' +
|
|
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png" target="_blank" rel="noopener noreferrer" title="translated: Download file.png">upload</a> ' +
|
|
"<a>invalid</a> " +
|
|
"<a>unsafe</a> " +
|
|
'<a href="/#fragment" title="http://zulip.zulipdev.com/#fragment">fragment</a>' +
|
|
'<div class="message_inline_image">' +
|
|
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.png" target="_blank" rel="noopener noreferrer" aria-label="inline image">upload</a> ' +
|
|
'<a role="button">button</a> ' +
|
|
"</div>",
|
|
);
|
|
});
|