Problem
The image URL builder form on the landing page performs no input validation beyond checking for an empty source URL. Invalid inputs produce no visual error message.
Location: internal/web/views/landing.templ:90-143
Missing Validation
| Input |
HTML Attribute |
Issue |
<input type="text" id="b-src"> |
No required, no pattern |
Empty/invalid URLs silently show placeholder text |
<input type="number" id="b-w" min="1" max="4096"> |
min/max set but no custom error |
Values outside range show browser default tooltip |
<input type="number" id="b-q" min="1" max="100"> |
min/max set but no custom error |
Same as above |
The JavaScript build() function at lines 115-143 performs no validation beyond if (!u) for empty source.
Proposed Fix
- Add visual error styling (red border) for invalid inputs
- Show inline error messages below or beside invalid fields
- Validate URL format before attempting to load the preview
- Add
required attributes to mandatory fields
- Consider using the Constraint Validation API for custom messages
Example
function validate() {
let valid = true;
const src = document.getElementById("b-src");
const w = document.getElementById("b-w");
const q = document.getElementById("b-q");
if (!src.value) {
src.classList.add("error");
valid = false;
} else {
src.classList.remove("error");
}
if (w.value && (w.value < 1 || w.value > 4096)) {
w.classList.add("error");
valid = false;
} else {
w.classList.remove("error");
}
// ... similar for q
return valid;
}
.builder input.error {
border-color: #d73a49;
background: #ffeef0;
}
Problem
The image URL builder form on the landing page performs no input validation beyond checking for an empty source URL. Invalid inputs produce no visual error message.
Location:
internal/web/views/landing.templ:90-143Missing Validation
<input type="text" id="b-src">required, nopattern<input type="number" id="b-w" min="1" max="4096">min/maxset but no custom error<input type="number" id="b-q" min="1" max="100">min/maxset but no custom errorThe JavaScript
build()function at lines 115-143 performs no validation beyondif (!u)for empty source.Proposed Fix
requiredattributes to mandatory fieldsExample