mirror of
https://github.com/direct-img/direct-img.link.git
synced 2026-03-17 03:01:01 +00:00
Feat: Reject queries with slashes, serve bad.webp
This commit is contained in:
@@ -4,7 +4,7 @@ export async function onRequest(context) {
|
|||||||
const path = params.path?.join("/") || "";
|
const path = params.path?.join("/") || "";
|
||||||
|
|
||||||
// Serve static assets for root or standard files
|
// Serve static assets for root or standard files
|
||||||
if (!path || path === "index.html" || path === "favicon.ico" || path === "robots.txt" || path === "limit.webp") {
|
if (!path || path === "index.html" || path === "favicon.ico" || path === "robots.txt" || path === "limit.webp" || path === "bad.webp") {
|
||||||
return env.ASSETS.fetch(request);
|
return env.ASSETS.fetch(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,6 +13,12 @@ export async function onRequest(context) {
|
|||||||
return jsonResponse(400, { error: "Empty query" });
|
return jsonResponse(400, { error: "Empty query" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reject queries containing slashes (bot probes like wp-admin/setup-config.php)
|
||||||
|
if (query.includes("/")) {
|
||||||
|
const badReq = new Request(new URL("/bad.webp", url.origin));
|
||||||
|
return env.ASSETS.fetch(badReq);
|
||||||
|
}
|
||||||
|
|
||||||
// Max query length: 200 chars after normalization
|
// Max query length: 200 chars after normalization
|
||||||
if (query.length > 200) {
|
if (query.length > 200) {
|
||||||
return jsonResponse(400, { error: "Query too long (max 200 characters)" });
|
return jsonResponse(400, { error: "Query too long (max 200 characters)" });
|
||||||
|
|||||||
Reference in New Issue
Block a user