Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

update load price chart #1182

wants to merge 5 commits into from

Conversation

haunv3
Copy link
Contributor

@haunv3 haunv3 commented Apr 21, 2025

No description provided.

trungbach
trungbach previously approved these changes Apr 21, 2025
quangdz1704
quangdz1704 previously approved these changes Apr 21, 2025
Copy link
Contributor

@quangdz1704 quangdz1704 left a 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

@haunv3 haunv3 dismissed stale reviews from quangdz1704 and trungbach via 4cab703 April 22, 2025 04:08
Copy link

cloudflare-workers-and-pages bot commented Apr 22, 2025

Deploying beta-oraidex with  Cloudflare Pages  Cloudflare Pages

Latest commit: 57252ae
Status: ✅  Deploy successful!
Preview URL: https://840cc62f.beta-oraidex.pages.dev

View logs

@@ -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
is reinterpreted as HTML without escaping meta-characters.

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:

  1. Using a utility function to validate the URL format and ensure it points to an image.
  2. 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.


Suggested changeset 1
src/pages/UniversalSwap/Swap/components/InputSwap/InputSwap.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/pages/UniversalSwap/Swap/components/InputSwap/InputSwap.tsx b/src/pages/UniversalSwap/Swap/components/InputSwap/InputSwap.tsx
--- a/src/pages/UniversalSwap/Swap/components/InputSwap/InputSwap.tsx
+++ b/src/pages/UniversalSwap/Swap/components/InputSwap/InputSwap.tsx
@@ -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} />
EOF
@@ -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} />
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants