Repository navigation
fix: restrict search inputs - #2078
calebwongg wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
cubic analysis
No issues found across 3 files
Linked issue analysis
Linked issue: icssc/AntAlmanac#2065: Restrict search field inputs
| Status | Acceptance criteria | Notes |
|---|---|---|
| Allow numbers only in the section code | The handler removes other characters but still permits commas and hyphens, so it is not numbers-only. | |
| ✅ | Disallow numbers in instructor names | InstructorField strips every digit on change while leaving names with punctuation intact. |
| ✅ | Allow numbers or the correctly ordered VAR exception for units | UnitsField accepts digits and the VAR prefix sequence, normalizing letters to uppercase. |
|
/deploy |
| onChange: (event) => { | ||
| const upper = event.target.value.toUpperCase(); | ||
|
|
||
| if (upper.startsWith('VAR')) { | ||
| setUnits('VAR'); | ||
| } else if ('VAR'.startsWith(upper)) { | ||
| setUnits(upper); | ||
| } else { | ||
| setUnits(upper.replace(/[^0-9]/g, '')); | ||
| } | ||
| }, |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/antalmanac-scheduler/site/src/components/RightPane/CoursePane/SearchForm/ManualSearch/AdvancedSearch/AdvancedSearchFields/UnitsField.tsx">
<violation number="1" location="apps/antalmanac-scheduler/site/src/components/RightPane/CoursePane/SearchForm/ManualSearch/AdvancedSearch/AdvancedSearchFields/UnitsField.tsx:21">
P2: This regex keeps every decimal point, so inputs such as `1.2.3` and `..` are accepted even though they are not numbers. Retain at most one decimal point so malformed pasted values cannot be sent as the `units` query.</violation>
</file>
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Re-trigger cubic
| } else if ('VAR'.startsWith(upper)) { | ||
| setUnits(upper); | ||
| } else { | ||
| setUnits(upper.replace(/[^0-9.]/g, '')); |
There was a problem hiding this comment.
P2: This regex keeps every decimal point, so inputs such as 1.2.3 and .. are accepted even though they are not numbers. Retain at most one decimal point so malformed pasted values cannot be sent as the units query.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/antalmanac-scheduler/site/src/components/RightPane/CoursePane/SearchForm/ManualSearch/AdvancedSearch/AdvancedSearchFields/UnitsField.tsx, line 21:
<comment>This regex keeps every decimal point, so inputs such as `1.2.3` and `..` are accepted even though they are not numbers. Retain at most one decimal point so malformed pasted values cannot be sent as the `units` query.</comment>
<file context>
@@ -18,7 +18,7 @@ export const UnitsField = memo(() => {
setUnits(upper);
} else {
- setUnits(upper.replace(/[^0-9]/g, ''));
+ setUnits(upper.replace(/[^0-9.]/g, ''));
}
},
</file context>
|
/deploy |
…/restrict-search-inputs
|
@calebwongg pull main it has fixes for the type errors blocking deployments |
…/restrict-search-inputs
|
hooray |
| onChange: (event) => { | ||
| const upper = event.target.value.toUpperCase(); | ||
|
|
||
| if (upper.startsWith('VAR')) { | ||
| setUnits('VAR'); | ||
| } else if ('VAR'.startsWith(upper)) { | ||
| setUnits(upper); | ||
| } else { | ||
| const cleaned = upper.replace(/[^0-9.]/g, ''); | ||
| const finalValue = cleaned.replace(/(\..*?)\./g, '$1'); | ||
| setUnits(finalValue); |
There was a problem hiding this comment.
Is it intended that typing a number or dot resets the VAR progress? For example typing V, A, 1 shows V, VA, 1

Summary
Restricts what can be typed into three manual search fields so invalid characters are dropped on input instead of being sent to the API. Section Code keeps digits plus commas, hyphens, and spaces so comma lists and ranges like 29000-29100 still work. Instructor rejects digits, and Units accepts either a number or the literal VAR, typed letter by letter.
Screenshots
Test Plan
use nuqs to verify sanitizing
Issues
Closes #2065