Skip to content

Commit

Permalink
Merge pull request #9 from railwayapp/fp/sanitize-args
Browse files Browse the repository at this point in the history
sanitize args before rendering error html
  • Loading branch information
FarazPatankar authored Feb 1, 2024
2 parents dca0837 + fb61282 commit cd8e145
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/api/image.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NextApiHandler } from "next";
import { getLayoutAndConfig } from "../../layouts";
import { z } from "zod";

import { getLayoutAndConfig } from "../../layouts";
import { renderLayoutToSVG, renderSVGToPNG } from "../../og";
import { sanitizeHtml } from "../../layouts/utils";

const imageReq = z.object({
layoutName: z.string(),
Expand Down Expand Up @@ -38,7 +40,9 @@ const handler: NextApiHandler = async (req, res) => {
res.statusCode = 500;
res.setHeader("Content-Type", "text/html");
res.end(
`<h1>Internal Error</h1><pre><code>${(e as any).message}</code></pre>`,
`<h1>Internal Error</h1><pre><code>${sanitizeHtml(
(e as any).message,
)}</code></pre>`,
);
console.error(e);
}
Expand Down

0 comments on commit cd8e145

Please sign in to comment.