Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): escape HTML in Google Drive OAuth callback pages

Richie McIlroy81597dad6a26
diff --git a/apps/web/app/api/desktop/[...route]/storage.ts b/apps/web/app/api/desktop/[...route]/storage.ts
index bef91fdc0..374f1cff2 100644
--- a/apps/web/app/api/desktop/[...route]/storage.ts
+++ b/apps/web/app/api/desktop/[...route]/storage.ts
@@ -74,12 +74,20 @@ const verifyGoogleDriveState = (state: string) => {
return User.UserId.make(parsed.userId);
};
+const escapeHtml = (value: string) =>
+ value
+ .replace(/&/g, "&")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/"/g, "&quot;")
+ .replace(/'/g, "&#39;");
+
const htmlResponse = (title: string, body: string) => `<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
-<title>${title}</title>
+<title>${escapeHtml(title)}</title>
<style>
body{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;margin:0;min-height:100vh;display:grid;place-items:center;background:#f6f5f3;color:#1f1f1f}
main{max-width:480px;padding:32px;text-align:center}