Inhibit url previews on MXIDs containing slashes same as those without (#11160)

This commit is contained in:
Michael Telatynski 2023-07-03 16:56:58 +01:00 committed by GitHub
parent cfc13c58cd
commit 90b572f074
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -388,6 +388,14 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
return false;
}
const url = node.getAttribute("href");
const host = url?.match(/^https?:\/\/(.*?)(\/|$)/)?.[1];
// never preview permalinks (if anything we should give a smart
// preview of the room/user they point to: nobody needs to be reminded
// what the matrix.to site looks like).
if (!host || isPermalinkHost(host)) return false;
// as a random heuristic to avoid highlighting things like "foo.pl"
// we require the linked text to either include a / (either from http://
// or from a full foo.bar/baz style schemeless URL) - or be a markdown-style
@ -397,14 +405,6 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
return true;
}
const url = node.getAttribute("href");
const host = url?.match(/^https?:\/\/(.*?)(\/|$)/)?.[1];
// never preview permalinks (if anything we should give a smart
// preview of the room/user they point to: nobody needs to be reminded
// what the matrix.to site looks like).
if (!host || isPermalinkHost(host)) return false;
if (node.textContent?.toLowerCase().trim().startsWith(host.toLowerCase())) {
// it's a "foo.pl" style link
return false;