fix: an image link was reaching maximum regex stack depth (#5495)
Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
This commit is contained in:
parent
a9abf322c4
commit
e5746451ba
|
@ -16,7 +16,7 @@ import MarkdownTableRow from './TableRow';
|
|||
import MarkdownTableCell from './TableCell';
|
||||
import mergeTextNodes from './mergeTextNodes';
|
||||
import styles from './styles';
|
||||
import { isValidURL } from '../../lib/methods/helpers/url';
|
||||
import { isValidUrl } from '../../lib/methods/helpers/isValidUrl';
|
||||
import NewMarkdown from './new';
|
||||
import { formatText } from './formatText';
|
||||
import { IUserMention, IUserChannel, TOnLinkPress } from './interfaces';
|
||||
|
@ -246,7 +246,7 @@ class Markdown extends PureComponent<IMarkdownProps, any> {
|
|||
};
|
||||
|
||||
renderImage = ({ src }: { src: string }) => {
|
||||
if (!isValidURL(src)) {
|
||||
if (!isValidUrl(src)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export * from './isReadOnly';
|
|||
export * from './media';
|
||||
export * from './room';
|
||||
export * from './server';
|
||||
export * from './url';
|
||||
export * from './isSsl';
|
||||
export * from './isValidEmail';
|
||||
export * from './random';
|
||||
export * from './image';
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// Use checkUseSsl: false only if server url starts with http://
|
||||
export const isSsl = (url: string): boolean => !/http:\/\//.test(url);
|
|
@ -1,15 +0,0 @@
|
|||
export const isValidURL = (url: string): boolean => {
|
||||
const pattern = new RegExp(
|
||||
'^(https?:\\/\\/)?' + // protocol
|
||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
|
||||
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
|
||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
|
||||
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
|
||||
'(\\#[-a-z\\d_]*)?$',
|
||||
'i'
|
||||
); // fragment locator
|
||||
return !!pattern.test(url);
|
||||
};
|
||||
|
||||
// Use checkUseSsl: false only if server url starts with http://
|
||||
export const isSsl = (url: string): boolean => !/http:\/\//.test(url);
|
|
@ -3,7 +3,7 @@ import EJSON from 'ejson';
|
|||
import isEmpty from 'lodash/isEmpty';
|
||||
|
||||
import { twoFactor } from './twoFactor';
|
||||
import { isSsl } from '../methods/helpers/url';
|
||||
import { isSsl } from '../methods/helpers/isSsl';
|
||||
import { store as reduxStore } from '../store/auxStore';
|
||||
import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../definitions/rest/helpers';
|
||||
import { compareServerVersion, random } from '../methods/helpers';
|
||||
|
|
Loading…
Reference in New Issue