More external URL safety
This commit is contained in:
parent
9b2d498715
commit
30685d6102
@ -46,6 +46,15 @@
|
|||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
position: absolute;
|
||||||
|
right: 0.125rem;
|
||||||
|
top: 0.125rem;
|
||||||
|
display: block;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.row:first-of-type .Button {
|
.row:first-of-type .Button {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ const InlineButtons: FC<OwnProps> = ({ message, onClick }) => {
|
|||||||
onClick={() => onClick({ button })}
|
onClick={() => onClick({ button })}
|
||||||
>
|
>
|
||||||
{button.text}
|
{button.text}
|
||||||
|
{button.type === 'url' && <i className="icon-arrow-right" />}
|
||||||
</Button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -35,6 +35,7 @@ export type OwnProps = {
|
|||||||
size?: 'inline' | 'pictogram';
|
size?: 'inline' | 'pictogram';
|
||||||
shouldAffectAppendix?: boolean;
|
shouldAffectAppendix?: boolean;
|
||||||
dimensions?: IMediaDimensions & { isSmall?: boolean };
|
dimensions?: IMediaDimensions & { isSmall?: boolean };
|
||||||
|
nonInteractive?: boolean;
|
||||||
onClick?: (id: number) => void;
|
onClick?: (id: number) => void;
|
||||||
onCancelUpload?: (message: ApiMessage) => void;
|
onCancelUpload?: (message: ApiMessage) => void;
|
||||||
};
|
};
|
||||||
@ -51,6 +52,7 @@ const Photo: FC<OwnProps> = ({
|
|||||||
uploadProgress,
|
uploadProgress,
|
||||||
size = 'inline',
|
size = 'inline',
|
||||||
dimensions,
|
dimensions,
|
||||||
|
nonInteractive,
|
||||||
shouldAffectAppendix,
|
shouldAffectAppendix,
|
||||||
onClick,
|
onClick,
|
||||||
onCancelUpload,
|
onCancelUpload,
|
||||||
@ -117,7 +119,7 @@ const Photo: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const className = buildClassName(
|
const className = buildClassName(
|
||||||
'media-inner',
|
'media-inner',
|
||||||
!isUploading && 'interactive',
|
!isUploading && !nonInteractive && 'interactive',
|
||||||
isSmall && 'small-image',
|
isSmall && 'small-image',
|
||||||
width === height && 'square-image',
|
width === height && 'square-image',
|
||||||
);
|
);
|
||||||
|
|||||||
@ -42,12 +42,8 @@ const WebPage: FC<OwnProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleMediaClick = useCallback(() => {
|
const handleMediaClick = useCallback(() => {
|
||||||
if (webPage && (isSquarePhoto || webPage.hasDocument)) {
|
onMediaClick!();
|
||||||
window.open(webPage.url);
|
}, [onMediaClick]);
|
||||||
} else if (onMediaClick) {
|
|
||||||
onMediaClick();
|
|
||||||
}
|
|
||||||
}, [webPage, isSquarePhoto, onMediaClick]);
|
|
||||||
|
|
||||||
if (!webPage) {
|
if (!webPage) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -62,6 +58,7 @@ const WebPage: FC<OwnProps> = ({
|
|||||||
photo,
|
photo,
|
||||||
} = webPage;
|
} = webPage;
|
||||||
|
|
||||||
|
const isMediaInteractive = photo && onMediaClick && !isSquarePhoto && !webPage.hasDocument;
|
||||||
const truncatedDescription = trimText(description, MAX_TEXT_LENGTH);
|
const truncatedDescription = trimText(description, MAX_TEXT_LENGTH);
|
||||||
|
|
||||||
const className = buildClassName(
|
const className = buildClassName(
|
||||||
@ -82,7 +79,8 @@ const WebPage: FC<OwnProps> = ({
|
|||||||
observeIntersection={observeIntersection}
|
observeIntersection={observeIntersection}
|
||||||
shouldAutoLoad={shouldAutoLoad}
|
shouldAutoLoad={shouldAutoLoad}
|
||||||
size={isSquarePhoto ? 'pictogram' : 'inline'}
|
size={isSquarePhoto ? 'pictogram' : 'inline'}
|
||||||
onClick={handleMediaClick}
|
nonInteractive={!isMediaInteractive}
|
||||||
|
onClick={isMediaInteractive ? handleMediaClick : undefined}
|
||||||
onCancelUpload={onCancelMediaTransfer}
|
onCancelUpload={onCancelMediaTransfer}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ addReducer('clickInlineButton', (global, actions, payload) => {
|
|||||||
if (button.value.match(RE_TME_INVITE_LINK) || button.value.match(RE_TME_LINK)) {
|
if (button.value.match(RE_TME_INVITE_LINK) || button.value.match(RE_TME_LINK)) {
|
||||||
actions.openTelegramLink({ url: button.value });
|
actions.openTelegramLink({ url: button.value });
|
||||||
} else {
|
} else {
|
||||||
window.open(button.value);
|
actions.toggleSafeLinkModal({ url: button.value });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'callback': {
|
case 'callback': {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user