Homework2 - #22
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9ded99a. Configure here.
|
|
||
| if (item.isBought) { | ||
| li.innerHTML = ` | ||
| <span class="item-name crossed">${item.name}</span> |
There was a problem hiding this comment.
Unsanitized user input injected via innerHTML causes XSS
High Severity
item.name originates from user input (itemInput.value) and is interpolated directly into innerHTML without any sanitization. A user can enter HTML/script content as an item name (e.g., an <img> tag with an onerror handler), and it will be executed as part of the DOM. This data also persists in localStorage, making the XSS persistent across page loads.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 9ded99a. Configure here.
| input.addEventListener('blur', finishEditing); | ||
| input.addEventListener('keydown', (e) => { | ||
| if (e.key === 'Enter') finishEditing(); | ||
| }); |
There was a problem hiding this comment.
Double finishEditing fires on Enter key press
Medium Severity
finishEditing is bound to both blur and keydown (Enter). Pressing Enter calls finishEditing, which triggers saveAndRender() and rebuilds the DOM — removing the input element. This removal fires a blur event, calling finishEditing a second time, resulting in a redundant double save-and-render cycle. The blur listener needs to be removed (or guarded) when finishEditing is invoked from the Enter handler.
Reviewed by Cursor Bugbot for commit 9ded99a. Configure here.


Note
Medium Risk
Adds new client-side state management with
localStoragepersistence and dynamic DOM rendering; main risk is UI/state bugs (e.g., edit/amount/toggle flows) rather than security-critical logic.Overview
Replaces the previous static HTML/CSS placeholder with a styled BuyList shopping list layout (main list + sidebar summaries), including reusable button styles, tooltips, responsive layout, and print-specific styling.
Adds
script.jsto make the list interactive: items are rendered from in-memory state persisted tolocalStorage, with support for adding items, increment/decrement amount (min 1), marking bought/unbought, deleting items, and inline renaming via click-to-edit.Reviewed by Cursor Bugbot for commit 9ded99a. Bugbot is set up for automated code reviews on this repo. Configure here.