Include noreferrer on embed links / window.open.

This commit is contained in:
Paul 2021-09-17 09:37:07 +01:00
parent d5430a7920
commit 51f23f5aa0
4 changed files with 15 additions and 13 deletions

View file

@ -19,8 +19,6 @@ import { useCallback, useContext } from "preact/hooks";
import { internalEmit } from "../../lib/eventEmitter";
import { determineLink } from "../../lib/links";
import { getState } from "../../redux";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import { AppContext } from "../../context/revoltjs/RevoltClient";
@ -221,6 +219,7 @@ export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) {
}
case "external": {
element.setAttribute("target", "_blank");
element.setAttribute("rel", "noreferrer");
break;
}
}

View file

@ -151,15 +151,15 @@ export default function Intermediate(props: Props) {
id: "external_link_prompt",
link: link.href,
});
return true;
}
return false;
}
default: {
return true;
}
}
return true;
},
openScreen: (screen: Screen) => openScreen(screen),
writeClipboard: (text: string) => {

View file

@ -1,8 +1,9 @@
import { Text } from "preact-i18n";
import Modal from "../../../components/ui/Modal";
import { dispatch } from "../../../redux";
import Modal from "../../../components/ui/Modal";
interface Props {
onClose: () => void;
link: string;
@ -17,7 +18,7 @@ export function ExternalLinkModal({ onClose, link }: Props) {
actions={[
{
onClick: () => {
window.open(link, "_blank");
window.open(link, "_blank", "noreferrer");
onClose();
},
confirmation: true,
@ -36,15 +37,17 @@ export function ExternalLinkModal({ onClose, link }: Props) {
const url = new URL(link);
dispatch({
type: "TRUSTED_LINKS_ADD_DOMAIN",
domain: url.hostname
domain: url.hostname,
});
} catch(e) {}
window.open(link, "_blank");
} catch (e) {}
window.open(link, "_blank", "noreferrer");
onClose();
},
plain: true,
children: <Text id="app.special.modals.external_links.trust_domain" />,
}
children: (
<Text id="app.special.modals.external_links.trust_domain" />
),
},
]}>
<Text id="app.special.modals.external_links.short" /> <br />
<a>{link}</a>

View file

@ -53,7 +53,7 @@ export function Feedback() {
</CategoryButton>
</a>
<Link to="/invite/Testers">
<a target="_blank" rel="noreferrer">
<a>
<CategoryButton
hover
action="chevron"