diff --git a/index.js b/index.js index 904cff3..6048952 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ import express from "express"; import logRequest from "./logger.js"; import { parse } from "node-html-parser"; import { format } from "util"; +import escape from "escape-html"; const config = { FUCKING_ENDPOINT: @@ -30,7 +31,11 @@ app.get("/*/status/*", async (req, res) => { } catch (err) { return res .status(500) - .send("Error from Twitter API: " + format("%s", err)); + .send( + `

Error from Twitter API:

${escape(
+					format("%s", err)
+				)}
` + ); } if (twitter_res.status == 200) { let body; @@ -39,7 +44,11 @@ app.get("/*/status/*", async (req, res) => { } catch (err) { return res .status(500) - .send("Error from Twitter API: " + format("%s", err)); + .send( + `

Error from Twitter API:

${escape(
+						format("%s", err)
+					)}
` + ); } let html = parse(body.html); let block = html.firstChild; diff --git a/package-lock.json b/package-lock.json index 2560b2c..3729e31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "ejs": "^3.1.9", + "escape-html": "^1.0.3", "express": "^4.18.3", "node-html-parser": "^6.1.12" } diff --git a/package.json b/package.json index 726b5b1..60154ab 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "license": "ISC", "dependencies": { "ejs": "^3.1.9", + "escape-html": "^1.0.3", "express": "^4.18.3", "node-html-parser": "^6.1.12" }