Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Safely grab the OpenGraph title out of the URL preview for link safety (
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Jul 11, 2022
1 parent 0bc2f1c commit 62f3a9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/views/rooms/LinkPreviewWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ export default class LinkPreviewWidget extends React.Component<IProps> {
// opaque string. This does not allow any HTML to be injected into the DOM.
const description = AllHtmlEntities.decode(p["og:description"] || "");

const anchor = <a href={this.props.link} target="_blank" rel="noreferrer noopener">{ p["og:title"] }</a>;
const needsTooltip = PlatformPeg.get()?.needsUrlTooltips() && this.props.link !== p["og:title"].trim();
const title = p["og:title"]?.trim() ?? "";
const anchor = <a href={this.props.link} target="_blank" rel="noreferrer noopener">{ title }</a>;
const needsTooltip = PlatformPeg.get()?.needsUrlTooltips() && this.props.link !== title;

return (
<div className="mx_LinkPreviewWidget">
Expand Down

0 comments on commit 62f3a9a

Please sign in to comment.