mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: stronger enforcement of normalizeLink (#6728)
Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
b7350f9707
commit
b33fa6d6f6
10 changed files with 72 additions and 24 deletions
|
@ -291,13 +291,12 @@ import {
|
|||
} from "../element/textElement";
|
||||
import { isHittingElementNotConsideringBoundingBox } from "../element/collision";
|
||||
import {
|
||||
normalizeLink,
|
||||
showHyperlinkTooltip,
|
||||
hideHyperlinkToolip,
|
||||
Hyperlink,
|
||||
isPointHittingLinkIcon,
|
||||
isLocalLink,
|
||||
} from "../element/Hyperlink";
|
||||
import { isLocalLink, normalizeLink } from "../data/url";
|
||||
import { shouldShowBoundingBox } from "../element/transformHandles";
|
||||
import { actionUnlockAllElements } from "../actions/actionElementLock";
|
||||
import { Fonts } from "../scene/Fonts";
|
||||
|
@ -3352,12 +3351,19 @@ class App extends React.Component<AppProps, AppState> {
|
|||
this.device.isMobile,
|
||||
);
|
||||
if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {
|
||||
const url = this.hitLinkElement.link;
|
||||
let url = this.hitLinkElement.link;
|
||||
if (url) {
|
||||
url = normalizeLink(url);
|
||||
let customEvent;
|
||||
if (this.props.onLinkOpen) {
|
||||
customEvent = wrapEvent(EVENT.EXCALIDRAW_LINK, event.nativeEvent);
|
||||
this.props.onLinkOpen(this.hitLinkElement, customEvent);
|
||||
this.props.onLinkOpen(
|
||||
{
|
||||
...this.hitLinkElement,
|
||||
link: url,
|
||||
},
|
||||
customEvent,
|
||||
);
|
||||
}
|
||||
if (!customEvent?.defaultPrevented) {
|
||||
const target = isLocalLink(url) ? "_self" : "_blank";
|
||||
|
@ -3365,7 +3371,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
// https://mathiasbynens.github.io/rel-noopener/
|
||||
if (newWindow) {
|
||||
newWindow.opener = null;
|
||||
newWindow.location = normalizeLink(url);
|
||||
newWindow.location = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue