From 59e0a0fe4ff1bc1fd8ae0b5a036d36bd1307019f Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Sun, 7 Jun 2026 09:19:20 +0330 Subject: [PATCH] fix: resolve critical bugs and security issues across the project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Security: - Disable SSL verification only in development (lib/req.js) - Wrap all JSON.parse(cookie) calls in try-catch via safeJsonParse utility - Sanitize dangerouslySetInnerHTML in blog/clinic with sanitizeHtml utility - Fix open redirect in payment page — validate URL origin before redirect - Fix cookie cleanup on 401 — use js-cookie with correct domain scope Performance: - Wrap ItemDoctor with React.memo to prevent unnecessary re-renders - Replace with Next.js in blog Caption component Functionality: - Fix memory leak in Recode.js — store intervals in refs, cleanup on unmount - Add null guard on retryIcon.current before classList manipulation - Fix getParsedUserInfo in helper to handle malformed cookie gracefully Co-Authored-By: Claude Sonnet 4.6 --- app/component/ItemDoctor.js | 3 +- app/panel/(layout)/layout.js | 4 ++- app/payment/[uuid]/page.js | 9 +++-- components/appointment/index.js | 5 +-- components/blog/detail/Caption.js | 17 +++++---- .../clinic/components/about/TextDetail.js | 3 +- .../sidebars/transactions/index.js | 4 ++- .../register/verificationPage/Recode.js | 36 ++++++++++++++----- helper/index.js | 8 +++-- lib/ability.js | 7 ++-- lib/req.js | 7 ++-- lib/sanitize.js | 26 ++++++++++++++ services/api.js | 8 +++-- 13 files changed, 104 insertions(+), 33 deletions(-) create mode 100644 lib/sanitize.js diff --git a/app/component/ItemDoctor.js b/app/component/ItemDoctor.js index 938d9eb..64ee0ed 100644 --- a/app/component/ItemDoctor.js +++ b/app/component/ItemDoctor.js @@ -1,3 +1,4 @@ +import { memo } from "react"; import Image from "next/image"; import { Button } from "@mui/material"; import Link from "next/link"; @@ -109,4 +110,4 @@ function ItemDoctor({ doctor, loading, setDoctors, priority = false }) { ); } -export default ItemDoctor; +export default memo(ItemDoctor); diff --git a/app/panel/(layout)/layout.js b/app/panel/(layout)/layout.js index 7423622..d793db7 100644 --- a/app/panel/(layout)/layout.js +++ b/app/panel/(layout)/layout.js @@ -4,6 +4,7 @@ import { getUser } from "@/lib/auth"; import { redirect } from "next/navigation"; import { cookies } from "next/headers"; import { fetchReq } from "@/lib/req"; +import { safeJsonParse } from "@/lib/sanitize"; async function LayoutPanel({ children }) { const user = await getUser(); @@ -22,7 +23,8 @@ async function LayoutPanel({ children }) { const accessToken = cookieStore.get("access_token"); if (userInfo && accessToken) { - const parsedUserInfo = JSON.parse(userInfo.value); + const parsedUserInfo = safeJsonParse(userInfo.value); + if (!parsedUserInfo) return; const representationUuid = parsedUserInfo?.representation_uuid; if (representationUuid) { diff --git a/app/payment/[uuid]/page.js b/app/payment/[uuid]/page.js index 68e2c90..28f09da 100644 --- a/app/payment/[uuid]/page.js +++ b/app/payment/[uuid]/page.js @@ -199,8 +199,13 @@ export default function PaymentDetailsPage() { <>