Fix lbry:// URLs in iframes being broken by Safari (#1812)
When Safari parses lbry:// URLs, it breaks them as they are not compliant with the RFC 3986 URI syntax. This causes iframes in text posts which link to a lbry:// URL to not display on Safari. Instead, just use the lbry:// URL matched from the iframe regex instead of parsing the iframe on Safari.
This commit is contained in:
parent
54122f8998
commit
fc32339d2d
1 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, MISSING_THUMB_DEFAULT } from 'config';
|
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, MISSING_THUMB_DEFAULT } from 'config';
|
||||||
|
import { platform } from 'util/platform';
|
||||||
import { formattedEmote, inlineEmote } from 'util/remark-emote';
|
import { formattedEmote, inlineEmote } from 'util/remark-emote';
|
||||||
import { formattedLinks, inlineLinks } from 'util/remark-lbry';
|
import { formattedLinks, inlineLinks } from 'util/remark-lbry';
|
||||||
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
|
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
|
||||||
|
@ -141,7 +142,7 @@ const schema = { ...defaultSchema };
|
||||||
schema.protocols.href.push('lbry');
|
schema.protocols.href.push('lbry');
|
||||||
schema.attributes.a.push('embed');
|
schema.attributes.a.push('embed');
|
||||||
|
|
||||||
const REPLACE_REGEX = /(<iframe\s+src=["'])(.*?(?=))(["']\s*><\/iframe>)/g;
|
const REPLACE_REGEX = /(?:<iframe\s+src=["'])(.*?(?=))(?:["']\s*><\/iframe>)/g;
|
||||||
|
|
||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
|
@ -162,7 +163,11 @@ export default React.memo<MarkdownProps>(function MarkdownPreview(props: Markdow
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const strippedContent = content
|
const strippedContent = content
|
||||||
? content.replace(REPLACE_REGEX, (iframeHtml) => {
|
? content.replace(REPLACE_REGEX, (iframeHtml, iframeUrl) => {
|
||||||
|
if (platform.isSafari()) {
|
||||||
|
return iframeUrl;
|
||||||
|
}
|
||||||
|
|
||||||
// Let the browser try to create an iframe to see if the markup is valid
|
// Let the browser try to create an iframe to see if the markup is valid
|
||||||
const outer = document.createElement('div');
|
const outer = document.createElement('div');
|
||||||
outer.innerHTML = iframeHtml;
|
outer.innerHTML = iframeHtml;
|
||||||
|
|
Loading…
Reference in a new issue