diff --git a/passman-dev/php/passman/notes.php b/passman-dev/php/passman/notes.php index 2cadfba..59487ec 100644 --- a/passman-dev/php/passman/notes.php +++ b/passman-dev/php/passman/notes.php @@ -83,12 +83,17 @@ $result = $conn->query($sql_query); echo "

List of notes/comments

"; if (!empty($result) && $result->num_rows >= 1) { - while ($row = $result -> fetch_assoc()) { - echo "
"; - echo "
" . $row["note"] . "
"; - echo "
by " . $row["username"] . "
"; - echo "
"; - } + while ($row = $result -> fetch_assoc()) { + // Escape output to prevent stored XSS (DB content must be treated as untrusted). + $safe_note = htmlspecialchars($row["note"], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8"); + $safe_user = htmlspecialchars($row["username"], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8"); + + echo "
"; + echo "
" . $safe_note . "
"; + echo "
by " . $safe_user . "
"; + echo "
"; + } + // Free result set $result -> free_result();