From 62f3a9ae058a3c6157255171e0f7e5f112883758 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 11 Jul 2022 12:53:45 -0600 Subject: [PATCH] Safely grab the OpenGraph title out of the URL preview for link safety (#9028) --- src/components/views/rooms/LinkPreviewWidget.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/LinkPreviewWidget.tsx b/src/components/views/rooms/LinkPreviewWidget.tsx index af0b8a022e..25d5fdd00b 100644 --- a/src/components/views/rooms/LinkPreviewWidget.tsx +++ b/src/components/views/rooms/LinkPreviewWidget.tsx @@ -120,8 +120,9 @@ export default class LinkPreviewWidget extends React.Component { // opaque string. This does not allow any HTML to be injected into the DOM. const description = AllHtmlEntities.decode(p["og:description"] || ""); - const anchor = { p["og:title"] }; - const needsTooltip = PlatformPeg.get()?.needsUrlTooltips() && this.props.link !== p["og:title"].trim(); + const title = p["og:title"]?.trim() ?? ""; + const anchor = { title }; + const needsTooltip = PlatformPeg.get()?.needsUrlTooltips() && this.props.link !== title; return (