diff --git a/server/services/web.ts b/server/services/web.ts index 807c42531..78257bf17 100644 --- a/server/services/web.ts +++ b/server/services/web.ts @@ -111,7 +111,7 @@ export default function init(app: Koa = new Koa()): Koa { scriptSrc, styleSrc: ["'self'", "'unsafe-inline'", "github.githubassets.com"], imgSrc: ["*", "data:", "blob:"], - frameSrc: ["*"], + frameSrc: ["*", "data:"], connectSrc: ["*"], // Do not use connect-src: because self + websockets does not work in // Safari, ref: https://bugs.webkit.org/show_bug.cgi?id=201591 }, diff --git a/shared/embeds/Gist.tsx b/shared/embeds/Gist.tsx index 5d30953a3..edf56a943 100644 --- a/shared/embeds/Gist.tsx +++ b/shared/embeds/Gist.tsx @@ -1,4 +1,5 @@ import * as React from "react"; +import styled from "styled-components"; import { EmbedProps as Props } from "."; const URL_REGEX = new RegExp( @@ -8,64 +9,36 @@ const URL_REGEX = new RegExp( class Gist extends React.Component { static ENABLED = [URL_REGEX]; - ref = React.createRef(); - get id() { const gistUrl = new URL(this.props.attrs.href); return gistUrl.pathname.split("/")[2]; } - componentDidMount() { - this.updateIframeContent(); - } - - componentDidUpdate() { - this.updateIframeContent(); - } - - updateIframeContent = () => { - const iframe = this.ref.current; - if (!iframe) return; + render() { const id = this.id; - - // @ts-expect-error ts-migrate(2339) FIXME: Property 'document' does not exist on type 'HTMLIF... Remove this comment to see the full error message - let doc = iframe.document; - - if (iframe.contentDocument) { - doc = iframe.contentDocument; - } else if (iframe.contentWindow) { - doc = iframe.contentWindow.document; - } - const gistLink = `https://gist.github.com/${id}.js`; const gistScript = ``; const styles = ""; const iframeHtml = `${styles}${gistScript}`; - if (!doc) return; - doc.open(); - doc.writeln(iframeHtml); - doc.close(); - }; - render() { - const id = this.id; return ( -