Spaces:
Running
Running
JOHN SILLVESTOR commited on
Tighten blog origin and pay return checks
Browse files
server.js
CHANGED
|
@@ -516,11 +516,14 @@ function isBlogOrigin(o) {
|
|
| 516 |
if (!o || o.toLowerCase() === "null") return false;
|
| 517 |
try {
|
| 518 |
const u = new URL(o.includes("://") ? o : "https://" + o);
|
| 519 |
-
if (u.protocol !== "https:") return false;
|
|
|
|
| 520 |
const h = u.hostname.toLowerCase();
|
| 521 |
-
if (h === "dublk2000.blogspot.com"
|
| 522 |
const allow = String(ORIGIN || "").replace(/\/$/, "");
|
| 523 |
-
|
|
|
|
|
|
|
| 524 |
} catch {
|
| 525 |
return false;
|
| 526 |
}
|
|
@@ -2402,8 +2405,11 @@ async function handleVipStatus(req, res) {
|
|
| 2402 |
function blogReturn(u) {
|
| 2403 |
try {
|
| 2404 |
const p = new URL(String(u || ""), ORIGIN);
|
| 2405 |
-
if (p.protocol !== "https:" || p.
|
| 2406 |
-
|
|
|
|
|
|
|
|
|
|
| 2407 |
} catch {
|
| 2408 |
return ORIGIN + "/";
|
| 2409 |
}
|
|
|
|
| 516 |
if (!o || o.toLowerCase() === "null") return false;
|
| 517 |
try {
|
| 518 |
const u = new URL(o.includes("://") ? o : "https://" + o);
|
| 519 |
+
if (u.protocol !== "https:" || u.username || u.password) return false;
|
| 520 |
+
if (u.port && u.port !== "443") return false;
|
| 521 |
const h = u.hostname.toLowerCase();
|
| 522 |
+
if (h === "dublk2000.blogspot.com") return true;
|
| 523 |
const allow = String(ORIGIN || "").replace(/\/$/, "");
|
| 524 |
+
if (!allow) return false;
|
| 525 |
+
const au = new URL(allow);
|
| 526 |
+
return u.origin === au.origin && h === au.hostname.toLowerCase();
|
| 527 |
} catch {
|
| 528 |
return false;
|
| 529 |
}
|
|
|
|
| 2405 |
function blogReturn(u) {
|
| 2406 |
try {
|
| 2407 |
const p = new URL(String(u || ""), ORIGIN);
|
| 2408 |
+
if (p.protocol !== "https:" || p.username || p.password) return ORIGIN + "/";
|
| 2409 |
+
if (p.port && p.port !== "443") return ORIGIN + "/";
|
| 2410 |
+
if (p.hostname.toLowerCase() !== "dublk2000.blogspot.com") return ORIGIN + "/";
|
| 2411 |
+
const mobile = p.searchParams.get("m") === "1" ? "?m=1" : "";
|
| 2412 |
+
return p.origin + p.pathname + mobile;
|
| 2413 |
} catch {
|
| 2414 |
return ORIGIN + "/";
|
| 2415 |
}
|