Buchungskalender: öffentliche API gegen manipulierte IDs und Lookups absichern
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
035967f8eb
commit
0c5ca76a4d
3 files changed
+73
-7
No files matched your search
@@ -41,8 +41,11 @@ function schreiben(name, felder) {
|
||||
|
||||
const nichtGefunden = (err) => err?.status === 404 && err.type !== 'collection_not_found' && err.type !== 'database_not_found'
|
||||
|
||||
/** Dokument-IDs landen roh im URL-Pfad: nur harmlose Zeichen durchlassen. */
|
||||
export const ID_RE = /^[A-Za-z0-9_]{1,36}$/
|
||||
|
||||
async function ladeDok(name, id) {
|
||||
if (!id) return null
|
||||
if (typeof id !== 'string' || !ID_RE.test(id)) return null
|
||||
try {
|
||||
return lesen(name, await getDocument(config.collections[name], id))
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user