Skip to content

fix: add validation #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/library/zoid/message/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export default createGlobalVariableGetter('__paypal_credit_message__', () =>
const { modal, index, account, merchantId, currency, amount, buyerCountry, onApply } = props;
const { offerType, offerCountry, messageRequestId, lander } = meta;
if (offerType === 'PURCHASE_PROTECTION') {
getURIPopup(lander, offerType);
if (getURIPopup(lander, offerType) == null) {
logger.warn('Blocked unsafe lander URL', { lander });
}
} else {
// Avoid spreading message props because both message and modal
// zoid components have an onClick prop that functions differently
Expand Down
17 changes: 14 additions & 3 deletions src/utils/sdk.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable eslint-comments/disable-enable-pair, no-else-return */
import arrayFrom from 'core-js-pure/stable/array/from';

import { getStorage as getBelterStorage } from '@krakenjs/belter/src';
import { SDK_QUERY_KEYS, SDK_SETTINGS } from '@paypal/sdk-constants/src';
import {
Expand All @@ -22,7 +21,6 @@ import {
getDisableSetCookie as getSDKDisableCookie,
getPageType as getSDKPageType
} from '@paypal/sdk-client/src';

import { TAG } from './constants';

export function getDisableSetCookie() {
Expand Down Expand Up @@ -275,5 +273,18 @@ export function getFeatures(featureProps) {

// open mini-browser with message lander url
export function getURIPopup(lander, label) {
return window.open(lander, label, 'width=460,height=900');
try {
// eslint-disable-next-line compat/compat
const parsed = new URL(lander);
const isHttp = parsed.protocol === 'https:';
const isPayPalDomain = /\.paypal\.com$/i.test(parsed.hostname);

if (isHttp && isPayPalDomain) {
return window.open(lander, label, 'width=460,height=900');
} else {
return null;
}
} catch (e) {
return null;
}
}
Loading