From 068ac7feae3f310025c2e9789cf246a6c2f802a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 17:55:39 +0000 Subject: [PATCH 1/4] Initial plan From cc5e8504295a44ff08dde943720435090b874d41 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 18:01:43 +0000 Subject: [PATCH 2/4] fix: validate and allowlist language parameter against SUPPORTED_LANGUAGES PR #92 introduced a security vulnerability by replacing the language allowlist validation with `language = body.language || "English"`, which allows arbitrary values to be injected into the AI prompt. Restore the proper validation: - Check that body.language is a string - Normalize to title case - Validate against SUPPORTED_LANGUAGES allowlist - Fall back to "English" if not in the list This also includes the other improvements from PR #92 (markdown cleanup, gemini model update, UI language list). Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com> Agent-Logs-Url: https://github.com/BeyteFlow/ReadmeGenAI/sessions/486edd1a-2457-4589-b5e2-b61f6dfde55f --- README.md | 2 +- assets/{fearture-page.png => feature-page.png} | Bin src/app/api/generate/route.ts | 9 ++++++--- src/components/Generator/SearchInput.tsx | 17 +++++++++++++++-- src/lib/gemini.ts | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) rename assets/{fearture-page.png => feature-page.png} (100%) diff --git a/README.md b/README.md index 6cf4bd1..7cf68c9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ ReadmeGenAI eliminates this friction by leveraging advanced AI to automatically Main Page

- Feature Page + Feature Page

## Technical Architecture diff --git a/assets/fearture-page.png b/assets/feature-page.png similarity index 100% rename from assets/fearture-page.png rename to assets/feature-page.png diff --git a/src/app/api/generate/route.ts b/src/app/api/generate/route.ts index 8eaaeee..06044db 100644 --- a/src/app/api/generate/route.ts +++ b/src/app/api/generate/route.ts @@ -9,7 +9,7 @@ export const dynamic = "force-dynamic"; * AI README Generation Endpoint * Optimized for data accuracy, clean prompt interpolation, and multi-language support. * - * @param {Request} req - The incoming request object containing the repo URL and optional language. + * @param {Request} req - The incoming Fastify request object containing the repo URL and optional language. * @returns {Promise} A JSON response containing the generated Markdown or an error message. */ export async function POST(req: Request) { @@ -157,9 +157,12 @@ export async function POST(req: Request) { const result = await model.generateContent(prompt); const response = await result.response; - const markdown = response.text(); + const markdown = response.text().trim(); + const cleanMarkdown = markdown + .replace(/^```(markdown|md)?\n/, "") + .replace(/\n```$/, ""); - return NextResponse.json({ markdown }); + return NextResponse.json({ markdown: cleanMarkdown }); } catch (error: unknown) { const message = error instanceof Error ? error.message : "Internal Server Error"; diff --git a/src/components/Generator/SearchInput.tsx b/src/components/Generator/SearchInput.tsx index eee2617..dc3829b 100644 --- a/src/components/Generator/SearchInput.tsx +++ b/src/components/Generator/SearchInput.tsx @@ -29,6 +29,20 @@ export const SearchInput = ({ const [language, setLanguage] = useState("English"); const [error, setError] = useState(null); + const languages = [ + "English", + "Spanish", + "French", + "German", + "Chinese", + "Japanese", + "Korean", + "Portuguese", + "Russian", + "Arabic", + "Turkish", + ]; + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); setError(null); @@ -72,10 +86,9 @@ export const SearchInput = ({ setLanguage(e.target.value)} + aria-label="Select language for README generation" className="bg-zinc-900/50 border border-white/10 rounded-2xl px-6 py-6 text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all backdrop-blur-xl appearance-none cursor-pointer min-w-[140px]" > - {languages.map((lang) => ( + {SUPPORTED_LANGUAGES.map((lang) => (