Skip to content

Homework2 - #22

Open
BogdanHrytsenko52 wants to merge 4 commits into
seagullua:masterfrom
BogdanHrytsenko52:hw2
Open

Homework2#22
BogdanHrytsenko52 wants to merge 4 commits into
seagullua:masterfrom
BogdanHrytsenko52:hw2

Conversation

@BogdanHrytsenko52

@BogdanHrytsenko52 BogdanHrytsenko52 commented May 23, 2026

Copy link
Copy Markdown

Note

Medium Risk
Adds new client-side state management with localStorage persistence 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.js to make the list interactive: items are rendered from in-memory state persisted to localStorage, 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread script.js

if (item.isBought) {
li.innerHTML = `
<span class="item-name crossed">${item.name}</span>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9ded99a. Configure here.

Comment thread script.js
input.addEventListener('blur', finishEditing);
input.addEventListener('keydown', (e) => {
if (e.key === 'Enter') finishEditing();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9ded99a. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants