-
Notifications
You must be signed in to change notification settings - Fork 141
fix: Validate country field accepting numeric input #1714
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -701,15 +701,22 @@ const Settings = () => { | |
| <label className="block text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-2"> | ||
| Country | ||
| </label> | ||
|
|
||
| <input | ||
| type="text" | ||
| value={country} | ||
| onChange={(e) => setCountry(e.target.value)} | ||
| onChange={(e) => { | ||
| const value = e.target.value; | ||
|
|
||
| if (/^[A-Za-z\s'-]*$/.test(value)) { | ||
| setCountry(value); | ||
| } | ||
| }} | ||
| placeholder="Enter Country" | ||
| className="w-full bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-lg py-2.5 px-4 text-sm text-slate-900 dark:text-white" | ||
| /> | ||
|
Comment on lines
705
to
717
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Enforce country validation on the API boundary. This client-side filter does not protect persisted data. 🧰 Tools🪛 ast-grep (0.45.0)[warning] 711-711: Avoid using the initial state variable in setState (setstate-same-var) 🤖 Prompt for AI Agents🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Show an error and block save for invalid or empty country values. The handler silently keeps the previous value when the user enters 🧰 Tools🪛 ast-grep (0.45.0)[warning] 711-711: Avoid using the initial state variable in setState (setstate-same-var) 🤖 Prompt for AI Agents |
||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="border-t border-slate-200/60 dark:border-slate-800 pt-6"> | ||
| <h3 className="text-lg font-bold text-slate-950 dark:text-white mb-6"> | ||
| Educational Details | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Allow Unicode letters in country names.
The
[A-Za-z]pattern rejects valid names such asCôte d'IvoireandSão Tomé and Príncipe. Use Unicode-aware validation or a canonical country list while preserving spaces, apostrophes, and hyphens.🧰 Tools
🪛 ast-grep (0.45.0)
[warning] 711-711: Avoid using the initial state variable in setState
Context: setCountry(value)
Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.
(setstate-same-var)
🤖 Prompt for AI Agents