mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 12:45:11 +08:00
Fix issue with falsey hrefs being sent in events (#8113)
This commit is contained in:
parent
81df4c0aeb
commit
eb668538aa
@ -182,7 +182,11 @@ const transformTags: IExtendedSanitizeOptions["transformTags"] = { // custom to
|
|||||||
) {
|
) {
|
||||||
delete attribs.target;
|
delete attribs.target;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Delete the href attrib if it is falsey
|
||||||
|
delete attribs.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
attribs.rel = 'noreferrer noopener'; // https://mathiasbynens.github.io/rel-noopener/
|
attribs.rel = 'noreferrer noopener'; // https://mathiasbynens.github.io/rel-noopener/
|
||||||
return { tagName, attribs };
|
return { tagName, attribs };
|
||||||
},
|
},
|
||||||
|
@ -156,21 +156,21 @@ export const options = {
|
|||||||
// intercept local permalinks to users and show them like userids (in userinfo of current room)
|
// intercept local permalinks to users and show them like userids (in userinfo of current room)
|
||||||
try {
|
try {
|
||||||
const permalink = parsePermalink(href);
|
const permalink = parsePermalink(href);
|
||||||
if (permalink && permalink.userId) {
|
if (permalink?.userId) {
|
||||||
return {
|
return {
|
||||||
// @ts-ignore see https://linkify.js.org/docs/options.html
|
// @ts-ignore see https://linkify.js.org/docs/options.html
|
||||||
click: function(e) {
|
click: function(e: MouseEvent) {
|
||||||
onUserClick(e, permalink.userId);
|
onUserClick(e, permalink.userId);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// for events, rooms etc. (anything other then users)
|
// for events, rooms etc. (anything other than users)
|
||||||
const localHref = tryTransformPermalinkToLocalHref(href);
|
const localHref = tryTransformPermalinkToLocalHref(href);
|
||||||
if (localHref !== href) {
|
if (localHref !== href) {
|
||||||
// it could be converted to a localHref -> therefore handle locally
|
// it could be converted to a localHref -> therefore handle locally
|
||||||
return {
|
return {
|
||||||
// @ts-ignore see https://linkify.js.org/docs/options.html
|
// @ts-ignore see https://linkify.js.org/docs/options.html
|
||||||
click: function(e) {
|
click: function(e: MouseEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.location.hash = localHref;
|
window.location.hash = localHref;
|
||||||
},
|
},
|
||||||
@ -185,7 +185,7 @@ export const options = {
|
|||||||
case Type.UserId:
|
case Type.UserId:
|
||||||
return {
|
return {
|
||||||
// @ts-ignore see https://linkify.js.org/docs/options.html
|
// @ts-ignore see https://linkify.js.org/docs/options.html
|
||||||
click: function(e) {
|
click: function(e: MouseEvent) {
|
||||||
const userId = parsePermalink(href).userId;
|
const userId = parsePermalink(href).userId;
|
||||||
onUserClick(e, userId);
|
onUserClick(e, userId);
|
||||||
},
|
},
|
||||||
@ -193,7 +193,7 @@ export const options = {
|
|||||||
case Type.RoomAlias:
|
case Type.RoomAlias:
|
||||||
return {
|
return {
|
||||||
// @ts-ignore see https://linkify.js.org/docs/options.html
|
// @ts-ignore see https://linkify.js.org/docs/options.html
|
||||||
click: function(e) {
|
click: function(e: MouseEvent) {
|
||||||
const alias = parsePermalink(href).roomIdOrAlias;
|
const alias = parsePermalink(href).roomIdOrAlias;
|
||||||
onAliasClick(e, alias);
|
onAliasClick(e, alias);
|
||||||
},
|
},
|
||||||
@ -202,7 +202,7 @@ export const options = {
|
|||||||
case Type.GroupId:
|
case Type.GroupId:
|
||||||
return {
|
return {
|
||||||
// @ts-ignore see https://linkify.js.org/docs/options.html
|
// @ts-ignore see https://linkify.js.org/docs/options.html
|
||||||
click: function(e) {
|
click: function(e: MouseEvent) {
|
||||||
const groupId = parsePermalink(href).groupId;
|
const groupId = parsePermalink(href).groupId;
|
||||||
onGroupClick(e, groupId);
|
onGroupClick(e, groupId);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user