Skip to content

Commit

Permalink
fix: Coinbase wallet popup (#10996)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing security by adding `noopener noreferrer` to
`window.open` calls and introducing a new header for cross-origin
policies in the `next.config.mjs` file.

### Detailed summary
- Added a new header for `Cross-Origin-Opener-Policy` in
`next.config.mjs`.
- Updated `window.open` calls in:
  - `WalletModal.tsx` to include `noopener noreferrer`.
  - `ExternalCurrencyLink/index.tsx` to include `noopener noreferrer`.
- `StakeActions.tsx` for both `decreaseLink` and `increaseLink` to
include `noopener noreferrer`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
memoyil authored Dec 4, 2024
1 parent c3f1166 commit 4eb2d38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ const config = {
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin-allow-popups',
},
],
},
{
source: '/favicon.ico',
headers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export const V3ModifyStakeActions: React.FC<V3LiquidityActionsProps> = ({
decreaseLink,
}) => {
const onDecrease = useCallback(() => {
window.open(decreaseLink, '_blank', 'noopener')
window.open(decreaseLink, '_blank', 'noopener noreferrer')
}, [decreaseLink])
const onIncrease = useCallback(() => {
window.open(increaseLink, '_blank', 'noopener')
window.open(increaseLink, '_blank', 'noopener noreferrer')
}, [increaseLink])

return <ModifyStakeActions decreaseDisabled={decreaseDisabled} onIncrease={onIncrease} onDecrease={onDecrease} />
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-wallets/src/WalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function MobileModal<T>({
onClick={(wallet) => {
connectWallet(wallet)
if (wallet.deepLink && wallet.installed === false) {
window.open(wallet.deepLink)
window.open(wallet.deepLink, '_blank', 'noopener noreferrer')
}
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Props = {

export function ExternalCurrencyLink({ currencyLogo, title, desc, href, ...props }: Props) {
const onLinkClick = useCallback(() => {
window.open(href, "_blank");
window.open(href, "_blank", "noopener noreferrer");
}, [href]);

return (
Expand Down

0 comments on commit 4eb2d38

Please sign in to comment.