mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-29 10:26:49 -05:00
fix(security): santize query param on error page
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { HIDE_METADATA } from "../../utils/hide-metadata";
|
||||
import { createAuthEndpoint } from "../call";
|
||||
|
||||
function sanitize(input: string): string {
|
||||
return input
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
const html = (errorCode: string = "Unknown") => `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -78,7 +87,9 @@ const html = (errorCode: string = "Unknown") => `<!DOCTYPE html>
|
||||
<h1>Better Auth Error</h1>
|
||||
<p>We encountered an issue while processing your request. Please try again or contact the application owner if the problem persists.</p>
|
||||
<a href="/" id="returnLink" class="btn">Return to Application</a>
|
||||
<div class="error-code">Error Code: <span id="errorCode">${errorCode}</span></div>
|
||||
<div class="error-code">Error Code: <span id="errorCode">${sanitize(
|
||||
errorCode,
|
||||
)}</span></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
Reference in New Issue
Block a user