Skip to content

Commit 5d705ed

Browse files
committed
Fix parameter sanitization
1 parent 75429ef commit 5d705ed

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ app.get("/registry", async (req, res) => {
2727
})
2828

2929
app.post("/registry", async (req, res) => {
30-
const keyVal = await sanitizeString(key(req.body))
30+
const keyVal = await key(req.body)
3131
const urlVal = sanitizeString(url(req.body))
3232
const titleVal = sanitizeString(checkForBannedWords(req.body, "title"))
3333
const descriptionVal = sanitizeString(checkForBannedWords(req.body, "description"))

src/utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export function orderBy(body) {
1616
}
1717

1818
export async function key(body) {
19-
const keyVal = body.hasOwnProperty("key") ? body["key"] : ""
19+
const keyVal = body.hasOwnProperty("key") ? sanitizeString(body["key"]) : ""
2020
if ((await db.result(`SELECT * FROM users WHERE key = '${keyVal}'`, null, r => r.rowCount)) === 0) return ""
21+
return keyVal
2122
}
2223

2324
export function searchByTag(body) {

0 commit comments

Comments
 (0)