Skip to content

Fix: Enhance sanitizeRadius Function with NaN and Infinity Guards - #8877

Open
tmdeveloper007 wants to merge 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:fix/8845-sanitize-radius-nan-infinity-guard
Open

Fix: Enhance sanitizeRadius Function with NaN and Infinity Guards#8877
tmdeveloper007 wants to merge 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:fix/8845-sanitize-radius-nan-infinity-guard

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Extended sanitizeRadius to also check for Infinity values in addition to NaN. Added Math.round() to ensure the returned value is always an integer.

Changes Made

  • lib/svg/sanitizer.ts: Added Number.isFinite() check and Math.round() in sanitizeRadius

Impact it Made

  • Hardens the function against edge-case numeric inputs
  • Ensures returned value is always a clean integer

Closes #8845

Note: Please assign this PR to the tmdeveloper007 account.

@retenta-bot

retenta-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

This pull request effectively extends the sanitizeRadius function to handle edge cases by checking for both NaN and Infinity values. This aligns with previous decisions made to harden the function against unexpected numeric inputs and guarantees that the returned value is a clean integer. Thank you for your contribution, and please let me know if you need any further assistance!

@retenta-bot retenta-bot Bot changed the title fix : added NaN and Infinity guard in sanitizeRadius function Fix: Enhance sanitizeRadius Function with NaN and Infinity Guards Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4939.30 KB 4939.27 KB +0.03 KB (+0.00%)
Total CSS 348.46 KB 348.46 KB 0 B

@Aamod007 Aamod007 added level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected mentor:Aamod007 labels Aug 6, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work hardening the \sanitizeRadius\ utility in \lib/svg/sanitizer.ts. Adding \Number.isFinite()\ effectively protects against \Infinity\ values that could otherwise bypass the \isNaN\ check. I also appreciate the addition of \Math.round()\ before clamping to guarantee an integer output. Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix : add guard for NaN in sanitizeRadius parsed number

2 participants