-
Notifications
You must be signed in to change notification settings - Fork 21
update load price chart #1182
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
base: main
Are you sure you want to change the base?
update load price chart #1182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look good to copilot
Deploying beta-oraidex with
|
Latest commit: |
57252ae
|
Status: | ✅ Deploy successful! |
Preview URL: | https://840cc62f.beta-oraidex.pages.dev |
@@ -119,9 +119,9 @@ | |||
<div className={cx('left')}> | |||
<div className={cx('icon')}> | |||
{(token.icon && isConfirmToken === 'init') || isConfirmToken === 'confirmed' ? ( | |||
<img className={cx('logo')} src={token.icon} alt="icon" width={30} height={30} /> | |||
<img className={cx('logo')} style={{ borderRadius: '100%', backgroundColor: token?.coinGeckoId === 'usdai' ? 'white' : 'transparent' }} src={token.icon} alt="icon" width={30} height={30} /> |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the issue, we need to ensure that the token.icon
value is sanitized or validated before being used as the src
attribute of an <img>
tag. A common approach is to validate that the URL is a safe and valid image URL. This can be achieved by:
- Using a utility function to validate the URL format and ensure it points to an image.
- Replacing invalid or unsafe URLs with a default placeholder image.
The changes will be made in InputSwap.tsx
to validate the token.icon
value before rendering it. Additionally, we will introduce a utility function for URL validation.
-
Copy modified lines R17-R25 -
Copy modified line R27 -
Copy modified line R130
@@ -16,4 +16,13 @@ | ||
|
||
const cx = cn.bind(styles); | ||
const isValidImageUrl = (url: string | undefined): boolean => { | ||
if (!url) return false; | ||
try { | ||
const parsedUrl = new URL(url); | ||
return ['http:', 'https:'].includes(parsedUrl.protocol) && /\.(jpeg|jpg|gif|png|svg|webp)$/.test(parsedUrl.pathname); | ||
} catch { | ||
return false; | ||
} | ||
}; | ||
|
||
const cx = cn.bind(styles); | ||
interface InputSwapProps { | ||
@@ -120,3 +129,3 @@ | ||
<div className={cx('icon')}> | ||
{(token.icon && isConfirmToken === 'init') || isConfirmToken === 'confirmed' ? ( | ||
{(isValidImageUrl(token.icon) && isConfirmToken === 'init') || isConfirmToken === 'confirmed' ? ( | ||
<img className={cx('logo')} style={{ borderRadius: '100%', backgroundColor: token?.coinGeckoId === 'usdai' ? 'white' : 'transparent' }} src={token.icon} alt="icon" width={30} height={30} /> |
No description provided.