Zum Hauptinhalt springen
LIVE
CVSS 4.8CVE-2026-137621 | A weakness has been identified in RT-Thread up to 5.3.0. Affected by this vulnerability is the function bl_adc_get_value of the file bsp/bouffalo_lab/libraries/rt_drivers/drv_adc.c of the component Bouffalo ADC Driver. This manipulation of the argument channel causes improper validation of array index. The attack requires local access. Patch name: b3a0eb5e12c6dca8145fc49d76c4785478c9e55b. It is suggested to install a patch to address this issue.CVSS 6.7CVE-2026-137620 | A security flaw has been discovered in RT-Thread up to 5.3.0. Affected is the function davinci_spi_get_prescale of the file bsp/dm365/drivers/spi-davinci.c of the component DM365 SPI Driver. The manipulation of the argument max_hz results in divide by zero. The attack requires a local approach. The exploit has been released to the public and may be used for attacks. The patch is identified as e12183f7b87eddf182b95bf8b400acd626880306. Applying a patch is adviCVSS 4.8CVE-2026-137618 | A vulnerability was identified in RT-Thread up to 5.3.0. This impacts the function hpm_adc_enabled of the file bsp/hpmicro/libraries/drivers/drv_adc.c of the component HPM ADC Driver. The manipulation of the argument channel leads to improper validation of array index. The attack needs to be performed locally. The exploit is publicly available and might be used. The identifier of the patch is fc64f78669b42b35981f97c23c7e952832f3b48b. It is recommended to appCVSS 8.5CVE-2026-137506 | ezdxf through 1.4.5 contains a code injection vulnerability in the dxf2code add-on that allows attackers to inject Python code via unescaped single quotes in DXF table entry names. Attackers can craft a DXF file whose layer, linetype, style, or appid names break out of quoted strings in generated scripts, executing code with the privileges of the user running them.CVSS 7.1CVE-2026-137507 | torchvision before 0.29.2 contains a path traversal vulnerability in _extract_tar() that allows attackers to write files outside the extraction directory by supplying crafted tar archives. Attackers controlling archives passed to extract_archive() or download_and_extract_archive() can use .. paths, absolute paths, or symlinks to overwrite Python modules and achieve code execution.CVSS 8.5CVE-2026-137518 | pyfda through 0.9.5 contains an insecure deserialization vulnerability in load_filter() that allows attackers to execute code by supplying crafted .npz or .pkl filter files. Attackers can embed a __reduce__ gadget that runs via np.load with allow_pickle=True or pickle.load before validation, executing code with the user's privileges.CVSS 8.5CVE-2026-137529 | JAL (Just Another Ledger) through 2026.11.3 contains an arbitrary file overwrite vulnerability in backup restore that allows attackers to write files by supplying a crafted .tgz backup with a symlink member. Attackers can include a jal.sqlite symlink to an absolute path followed by a regular jal.sqlite member, overwriting files such as shell startup scripts for code execution.CVSS 8.7CVE-2026-137539 | lastversion before 3.6.20 contains a path traversal vulnerability in extract_tar() that allows attackers to write files outside the extraction directory via tar symlink members. Attackers controlling a project's release assets can craft a tarball with a symlink followed by a file beneath it, writing files like usercustomize.py to achieve code execution.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Build a Notes App with ctrodb, Tailwind CSS, and Vanilla JavaScript

Let's build a notes app that runs entirely in the browser. Create, pin, search, and delete notes — all persisted to IndexedDB. No backend, no build step, no n…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 10 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung

Let's build a notes app that runs entirely in the browser. Create, pin, search, and delete notes — all persisted to IndexedDB. No backend, no build step, no npm install.



We'll use ctrodb for the database, Tailwind CSS for styling, and vanilla JavaScript for the glue.






What we're building



A single HTML file with:




  • Add notes with title, body, and tags

  • Pin important notes to the top

  • Search notes by title

  • Delete notes

  • Persistence across page reloads

  • Dark mode UI






Setting up






<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ctrodb Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen p-4 sm:p-6">






ctrodb ships as an IIFE that exposes a CtroDB global:




<script src="https://unpkg.com/ctrodb@1.0.1/dist/index.global.js"></script>
<script>
const { Database } = CtroDB






No bundler, no build step, no npm install.






Schema design






const schema = {
version: 1,
collections: {
notes: {
fields: {
title: { type: "string", required: true },
body: { type: "string", default: "" },
tags: { type: "array", items: { type: "string" }, default: [] },
pinned: { type: "boolean", default: false },
createdAt: { type: "string", default: () => new Date().toISOString() },
},
indexes: [
{ field: "createdAt" },
{ field: "pinned" },
],
},
},
}






The schema validates every write. A note without a title throws a ValidationError. Defaults fill in missing fields.






Connecting






const db = new Database({ name: "notes-app", schema })
await db.connect()
const notes = db.collection("notes")









Rendering notes



Each note card carries its own id directly in the markup via a data-id attribute:




function noteCard(note) {
const isPinned = note.pinned
return `
<div class="bg-gray-800 rounded-lg p-4 border ..." data-id="
${note.id}">
<h3>
${escapeHtml(note.title)}</h3>
<button class="pin-btn ...">
${isPinned ? "\u2605" : "\u2606"}</button>
<button class="delete-btn ...">\u2715</button>
</div>
`

}

async function render(message) {
const query = document.getElementById("search").value.trim()
const list = query
? await notes.query().search("title", query).fetch()
: await notes.query().sort({ pinned: "desc", createdAt: "desc" }).fetch()

if (list.length === 0) {
container.innerHTML = `<p>${message || "No notes yet."}</p>`
return
}

container.innerHTML = list.map(noteCard).join("")
}






Notice render() only builds HTML — it doesn't attach any click handlers. That's deliberate, and it's the key to the next section.






Wiring up pin and delete with event delegation



A common first instinct is to attach a click listener to every .pin-btn and .delete-btn right after rendering, capturing the note from the list array by index:




// Don't do this — see below for why
container.querySelectorAll(".pin-btn").forEach((btn, i) => {
btn.addEventListener("click", async () => {
const note = list[i]
await note.update({ pinned: !note.pinned })
await render()
})
})






This works at first glance, but it has two real problems. Every call to render() re-attaches a fresh batch of listeners on top of whatever's still pending from the previous render, and the handler closes over the list array by position — so if a search or sort ever reorders things between render and click, the index can point at the wrong note.



The more robust pattern is event delegation: attach a single listener to the container once, and read the note's id off the clicked card's data-id attribute at click time.




container.addEventListener("click", async (e) => {
const card = e.target.closest("[data-id]")
if (!card) return
const id = Number(card.dataset.id)

if (e.target.closest(".pin-btn")) {
const note = await notes.get(id)
if (note) {
await note.update({ pinned: !note.pinned })
await render()
}
return
}

if (e.target.closest(".delete-btn")) {
await notes.delete(id)
await render()
}
})






One listener, attached once in init(), handles every note — present and future — since clicks bubble up to container regardless of how many times innerHTML gets replaced.






The one gotcha: dataset.id is always a string



This is the part that trips people up, so it's worth calling out explicitly. element.dataset.id always returns a string — "1", "2", and so on — because HTML attributes are text. But ctrodb's default browser adapter is IndexedDB, and with keyPath: "id", autoIncrement: true, the ids it actually stores are numbers.



IndexedDB key lookups are type-sensitive: the string "1" and the number 1 are different keys. So notes.get(card.dataset.id) silently fails to find anything — no error, no thrown exception, just an undefined result that your if (note) guard quietly swallows. From the UI, it just looks like the pin and delete buttons don't do anything.



The fix is the Number(...) call above:




const id = Number(card.dataset.id)






Easy to miss, easy to fix, and a good reminder that anything pulled from dataset needs to be coerced back to its real type before you use it as a database key.






Adding notes






document.getElementById("add-note-btn").addEventListener("click", async () => {
const title = document.getElementById("title").value.trim()
const body = document.getElementById("body").value.trim()
const tags = document.getElementById("tags").value
.split(",").map(t => t.trim()).filter(Boolean)

if (!title) { alert("Title is required."); return }

await notes.create({ title, body, tags })
clearForm()
await render()
})








A 200ms debounce avoids excessive queries:




let searchTimer
document.getElementById("search").addEventListener("input", () => {
clearTimeout(searchTimer)
searchTimer = setTimeout(() => render(), 200)
})






query().search("title", query) does case-insensitive substring matching.






Complete code



Here's the full HTML file:




<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ctrodb Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = { darkMode: "class" }
</script>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen p-4 sm:p-6">
<div class="max-w-2xl mx-auto">

<h1 class="text-3xl font-bold mb-8 flex items-center gap-3">
<span class="text-blue-400">◆</span>
ctrodb Notes
</h1>

<!-- Search -->
<div class="bg-gray-800 rounded-lg p-4 mb-6 border border-gray-700">
<input
id="search"
type="text"
placeholder="Search notes by title..."
class="w-full bg-gray-700 rounded px-3 py-2 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors"
/>
</div>

<!-- New Note Form -->
<div class="bg-gray-800 rounded-lg p-4 mb-6 border border-gray-700">
<h2 class="font-semibold mb-3 text-gray-300">New Note</h2>
<input
id="title"
type="text"
placeholder="Title (required)"
required
class="w-full bg-gray-700 rounded px-3 py-2 mb-3 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors"
/>
<textarea
id="body"
placeholder="Body (optional)"
rows="3"
class="w-full bg-gray-700 rounded px-3 py-2 mb-3 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors resize-none"
></textarea>
<input
id="tags"
type="text"
placeholder="Tags (comma-separated)"
class="w-full bg-gray-700 rounded px-3 py-2 mb-3 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors"
/>
<button
id="add-note-btn"
class="bg-blue-600 hover:bg-blue-500 text-white px-4 py-2 rounded font-medium transition-colors"
>
+ Add Note
</button>
</div>

<!-- Notes List -->
<div id="notes-container" class="space-y-3"></div>

</div>

<script src="https://unpkg.com/ctrodb@1.0.1/dist/index.global.js"></script>
<script>
const { Database } = CtroDB

const schema = {
version: 1,
collections: {
notes: {
fields: {
title: { type: "string", required: true },
body: { type: "string", default: "" },
tags: { type: "array", items: { type: "string" }, default: [] },
pinned: { type: "boolean", default: false },
createdAt: { type: "string", default: () => new Date().toISOString() },
},
indexes: [
{ field: "createdAt" },
{ field: "pinned" },
],
},
},
}

let db, notes, container

function escapeHtml(str) {
const div = document.createElement("div")
div.textContent = str
return div.innerHTML
}

function noteCard(note) {
const isPinned = note.pinned
return `
<div class="bg-gray-800 rounded-lg p-4 border transition-colors
${isPinned ? "border-yellow-500/60" : "border-gray-700"}" data-id="${note.id}">
<div class="flex items-start justify-between gap-4">
<div class="flex-1 min-w-0">
<h3 class="font-semibold text-lg truncate">
${escapeHtml(note.title)}</h3>
${note.body ? `<p class="text-gray-400 mt-1 line-clamp-3">${escapeHtml(note.body)}</p>` : ""}
${note.tags.length ? `
<div class="flex flex-wrap gap-2 mt-3">
${note.tags.map(t => `<span class="text-xs bg-gray-700 text-gray-300 px-2 py-0.5 rounded-full">${escapeHtml(t)}</span>`).join("")}
</div>
`
: ""}
<p class="text-xs text-gray-500 mt-3">
${new Date(note.createdAt).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })}</p>
</div>
<div class="flex gap-1 shrink-0">
<button class="pin-btn p-1.5 rounded hover:bg-gray-700 transition-colors
${isPinned ? "text-yellow-400" : "text-gray-500 hover:text-yellow-400"}" title="${isPinned ? "Unpin" : "Pin"}">
${isPinned ? "\u2605" : "\u2606"}
</button>
<button class="delete-btn p-1.5 rounded hover:bg-gray-700 text-gray-500 hover:text-red-400 transition-colors" title="Delete">\u2715</button>
</div>
</div>
</div>
`

}

function clearForm() {
document.getElementById("title").value = ""
document.getElementById("body").value = ""
document.getElementById("tags").value = ""
}

async function render(message) {
const query = document.getElementById("search").value.trim()
const list = query
? await notes.query().search("title", query).fetch()
: await notes.query().sort({ pinned: "desc", createdAt: "desc" }).fetch()

if (list.length === 0) {
container.innerHTML = `<p class="text-gray-500 text-center py-8">${message || (query ? "No notes match your search." : "No notes yet. Create one above!")}</p>`
return
}

container.innerHTML = list.map(noteCard).join("")
}

async function init() {
db = new Database({ name: "notes-app", schema })
await db.connect()
notes = db.collection("notes")
container = document.getElementById("notes-container")

// Add note
document.getElementById("add-note-btn").addEventListener("click", async () => {
const title = document.getElementById("title").value.trim()
const body = document.getElementById("body").value.trim()
const rawTags = document.getElementById("tags").value

if (!title) { alert("Title is required."); return }

const tags = rawTags.split(",").map(t => t.trim()).filter(Boolean)
await notes.create({ title, body, tags })
clearForm()
await render()
})

// Search with debounce
let searchTimer
document.getElementById("search").addEventListener("input", () => {
clearTimeout(searchTimer)
searchTimer = setTimeout(() => render(), 200)
})

// Event delegation for pin and delete
container.addEventListener("click", async (e) => {
const card = e.target.closest("[data-id]")
if (!card) return
const id = Number(card.dataset.id)

if (e.target.closest(".pin-btn")) {
const note = await notes.get(id)
if (note) {
await note.update({ pinned: !note.pinned })
await render()
}
return
}

if (e.target.closest(".delete-btn")) {
await notes.delete(id)
await render()
}
})

await render()
}

init()
</script>
</body>
</html>






Save it as notes.html and open it in any browser. Add notes, pin them, search, delete — all operations work with full IndexedDB persistence.






What's happening




  • ctrodb connects to IndexedDB, creates the notes-app database

  • The schema validates every write — wrong types or missing required fields throw


  • query().search("title", query) does case-insensitive substring matching

  • A single delegated click listener on #notes-container handles pin and delete for every note, current and future — no listeners to re-attach on each render

  • Ids read from data-id are coerced with Number(...) before being passed back to ctrodb, since IndexedDB's autoincrement keys are numeric but dataset values are always strings

  • Everything runs in-process — no network requests, no server



Try the browser playground at https://ctrodb.vercel.app/playground.






ctrodb is open source. GitHub: https://github.com/ctrotech-tutor/ctrodb. Docs: https://ctrodb.vercel.app/docs/getting-started/quick-start.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

Community Rating &amp; Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität
Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Verwandte Story-Cluster & Quellen (Vektor-KI)

6 Cluster
15 Quellen
Dyson may have just won Black Friday with a 59% discount on the V8 Cyclone — now just AU$268
Latest from TechRadar vor 37 Min.
14 weitere Quellen
Latest from TechRadarvor 1 Std.These are the best Nintendo Switch 2 Black Friday deals in Australia right now — save up to AU$142 on the latest console Latest from TechRadarvor 1 Std.Want the best bang for your buck? Tune in to our Black Friday livestream for the best deals in tech — from Apple and Samsung to LG, Nintendo and beyond Giga.devor 2 Std.Black-Friday-Sale bei Teufel: bis zu 500 Euro Rabatt auf die beliebten Sound-Bestseller PC-WELTvor 2 Std.Amazon startet Glücksrad am Black Friday: 10 Gutscheine im Wert von 2.000 Euro zu gewinnen PC-WELTvor 2 Std.Amazon startet Glücksrad am Black Friday: 10 Gutscheine im Wert von 2.000 Euro zu gewinnen Latest from TechRadarvor 2 Std.Black Friday Pre-sale checklist – do these 5 things before you start shopping Latest from TechRadarvor 2 Std.The Breville coffee machine we rely on in the TechRadar Australia kitchen is now AU$1,100 off for Black Friday Latest from TechRadarvor 2 Std.Black Friday US smartwatch deals 2026 — all picked by a wearable tech expert CNETvor 2 Std.I Found a Black Friday Deal That Takes $1,500 Off CNET’s Top-Rated 4K Laser Projector Latest from TechRadarvor 3 Std.Stop guessing which PS5 accessory to buy and take our Black Friday deal quiz Latest from TechRadarvor 4 Std.The only thing not affected by AI this Black Friday? Gaming monitors! Here's how to bag yourself a bargain OS X Dailyvor 4 Std.Black Friday Deals: $400 Off M5 MacBook Air! AirPods Pro 3 for $149! Latest from TechRadarvor 4 Std.The 2TB Samsung T9 portable SSD is $170 off this Black Friday CNETvor 4 Std.Buying a Kindle on Black Friday? We Compare Amazon’s E-Readers to Help You Choose the Best One
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Build a Notes App with ctrodb, Tailwind CSS, and Vanilla JavaScript

Thematisch verwandte Begriffe: Build, Notes, with, ctrodb · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag