From ee0e5f84e64aeb833416fffe56aa9385c79ddd3f Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 31 May 2026 15:14:03 +0800 Subject: [PATCH] fix: preserve proxy script crlf escapes --- scripts/g14-gitops-render.mjs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/g14-gitops-render.mjs b/scripts/g14-gitops-render.mjs index a98fe016..1aadc531 100644 --- a/scripts/g14-gitops-render.mjs +++ b/scripts/g14-gitops-render.mjs @@ -1119,7 +1119,7 @@ socket.setTimeout(10000, () => { }); socket.on("connect", () => { - socket.write("CONNECT " + targetHost + ":" + targetPort + " HTTP/1.1\r\nHost: " + targetHost + ":" + targetPort + "\r\nProxy-Connection: Keep-Alive\r\n\r\n"); + socket.write("CONNECT " + targetHost + ":" + targetPort + " HTTP/1.1\\r\\nHost: " + targetHost + ":" + targetPort + "\\r\\nProxy-Connection: Keep-Alive\\r\\n\\r\\n"); }); socket.on("error", (error) => { @@ -1129,10 +1129,10 @@ socket.on("error", (error) => { function onData(chunk) { buffer = Buffer.concat([buffer, chunk]); - const headerEnd = buffer.indexOf("\r\n\r\n"); + const headerEnd = buffer.indexOf("\\r\\n\\r\\n"); if (headerEnd === -1 && buffer.length < 8192) return; const head = buffer.slice(0, headerEnd + 4).toString("latin1"); - const statusLine = head.split("\r\n", 1)[0] || ""; + const statusLine = head.split("\\r\\n", 1)[0] || ""; const statusCode = Number.parseInt(statusLine.split(" ")[1] || "", 10); if (!statusLine.startsWith("HTTP/1.") || !Number.isInteger(statusCode) || statusCode < 200 || statusCode > 299) { console.error("proxy CONNECT rejected: " + (statusLine || "missing-status")); @@ -3146,14 +3146,14 @@ if (!proxyHost || !Number.isInteger(proxyPort) || !targetHost || !Number.isInteg const socket = net.createConnection({ host: proxyHost, port: proxyPort }); let buffer = Buffer.alloc(0); socket.setTimeout(10000, () => { socket.destroy(); process.exit(65); }); -socket.on("connect", () => socket.write("CONNECT " + targetHost + ":" + targetPort + " HTTP/1.1\r\nHost: " + targetHost + ":" + targetPort + "\r\nProxy-Connection: Keep-Alive\r\n\r\n")); +socket.on("connect", () => socket.write("CONNECT " + targetHost + ":" + targetPort + " HTTP/1.1\\r\\nHost: " + targetHost + ":" + targetPort + "\\r\\nProxy-Connection: Keep-Alive\\r\\n\\r\\n")); socket.on("error", () => process.exit(66)); function onData(chunk) { buffer = Buffer.concat([buffer, chunk]); - const headerEnd = buffer.indexOf("\r\n\r\n"); + const headerEnd = buffer.indexOf("\\r\\n\\r\\n"); if (headerEnd === -1 && buffer.length < 8192) return; const head = buffer.slice(0, headerEnd + 4).toString("latin1"); - const statusLine = head.split("\r\n", 1)[0] || ""; + const statusLine = head.split("\\r\\n", 1)[0] || ""; const statusCode = Number.parseInt(statusLine.split(" ")[1] || "", 10); if (!statusLine.startsWith("HTTP/1.") || !Number.isInteger(statusCode) || statusCode < 200 || statusCode > 299) { socket.destroy(); process.exit(67); } socket.off("data", onData); @@ -3392,14 +3392,14 @@ if (!proxyHost || !Number.isInteger(proxyPort) || !targetHost || !Number.isInteg const socket = net.createConnection({ host: proxyHost, port: proxyPort }); let buffer = Buffer.alloc(0); socket.setTimeout(10000, () => { socket.destroy(); process.exit(65); }); -socket.on("connect", () => socket.write("CONNECT " + targetHost + ":" + targetPort + " HTTP/1.1\r\nHost: " + targetHost + ":" + targetPort + "\r\nProxy-Connection: Keep-Alive\r\n\r\n")); +socket.on("connect", () => socket.write("CONNECT " + targetHost + ":" + targetPort + " HTTP/1.1\\r\\nHost: " + targetHost + ":" + targetPort + "\\r\\nProxy-Connection: Keep-Alive\\r\\n\\r\\n")); socket.on("error", () => process.exit(66)); function onData(chunk) { buffer = Buffer.concat([buffer, chunk]); - const headerEnd = buffer.indexOf("\r\n\r\n"); + const headerEnd = buffer.indexOf("\\r\\n\\r\\n"); if (headerEnd === -1 && buffer.length < 8192) return; const head = buffer.slice(0, headerEnd + 4).toString("latin1"); - const statusLine = head.split("\r\n", 1)[0] || ""; + const statusLine = head.split("\\r\\n", 1)[0] || ""; const statusCode = Number.parseInt(statusLine.split(" ")[1] || "", 10); if (!statusLine.startsWith("HTTP/1.") || !Number.isInteger(statusCode) || statusCode < 200 || statusCode > 299) { socket.destroy(); process.exit(67); } socket.off("data", onData);