MEDIUM: No input validation on canvas dimensions — zero/negative values cause rendering issues #6
Labels
No labels
blocked:lint-failed
blocked:needs-decision
blocked:needs-human
blocked:no-changes
blocked:pre-dispatch
bug
feature-request
in-progress
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/tokengenerator#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: MEDIUM
Location
tokengenerator.html, lines 205-208:Description
The width and height inputs accept any numeric value without validation. While the
|| 256fallback handles NaN/0 for the constant, the canvas still gets set to 0 width/height if someone types a 0 (because0 || 256evaluates to 256 in the variable, but wait — actuallyparseInt(0,10)returns 0 which is falsy, so it falls back to 256. However, Canvas specification accepts only positive integers. Invalid values like negative numbers pass through tocanvas.widthand can cause rendering artifacts or browser warnings.Additionally:
1.5silently truncate to integer.Recommended Fix
Math.min(Math.max(value, 50), 4096)(or similar reasonable bounds).minandmaxattributes to the input elements.Impact
Poor UX and potential browser instability with extreme values.