Skip to content

Conversation

@arjunkomath
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Sep 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
changes-page Ready Ready Preview Sep 13, 2025 5:32am
changes-page-docs Ready Ready Preview Sep 13, 2025 5:32am
user-changes-page Ready Ready Preview Sep 13, 2025 5:32am

@coderabbitai
Copy link

coderabbitai bot commented Sep 11, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +724 to +726
href={`${getPageUrl(page, settings)}/roadmap/${
boardForm.slug
}`}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI about 2 months ago

How to fix (in general terms):
Sanitize the user input used to construct URLs to ensure it does not contain dangerous or unexpected characters. Always encode or restrict such values so that generated links cannot contain JavaScript, extra slashes, or HTML characters.

Detailed fix (for this file):

  • Ensure boardForm.slug is a clean, "slug-safe" string before using it in the URL.
  • Best way: Sanitize the slug value right before rendering, even if upstream validation exists.
  • For visible text, React will escape text automatically; for href, ensure the interpolated slug cannot break out of the intended URL context (e.g., by starting with //, /, or javascript:).
  • In this case, implement a simple "escapeSlug" function to sanitize, and use it everywhere boardForm.slug is interpolated in a URL.
  • Optionally, if validateSlug() is robust and restrictions are checked on every input, one could reuse the generateSlugFromTitle logic or defensively replace non-slug characters just before rendering.

Specific changes:

  • In apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx:
    • Add an escapeSlug function (if not already present) that matches the slug rules (e.g., alphanumeric and hyphens only).
    • In the JSX where the slug is used, replace {boardForm.slug} with {escapeSlug(boardForm.slug)} in both href and visible text to ensure only safe characters are used in the link.

Needed:

  • Method: escapeSlug (definition in the component scope).
  • Imports: none (unless we want to use e.g., lodash's kebabCase, but a custom function is simple here).
  • Usage: Replace direct slug interpolation with escapeSlug(boardForm.slug) in all relevant places.

Suggested changeset 1
apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx b/apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx
--- a/apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx
+++ b/apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx
@@ -105,6 +105,15 @@
   categories,
   initialTab,
 }: InferGetServerSidePropsType<typeof getServerSideProps>) {
+  // Ensure the slug is strictly alphanumeric-hyphen for safety
+  function escapeSlug(slug: string): string {
+    return (slug || "")
+      .toLowerCase()
+      .replace(/[^a-z0-9-]/g, "")
+      .replace(/-+/g, "-")           // collapse multiple hyphens
+      .replace(/^-|-$/g, "");        // trim hyphens from ends
+  }
+
   const router = useRouter();
   const { supabase, user } = useUserData();
   const { settings: clientSettings } = usePageSettings(page_id, false);
@@ -759,13 +768,13 @@
                       Public URL:{" "}
                       <a
                         href={`${getPageUrl(page, settings)}/roadmap/${
-                          boardForm.slug
+                          escapeSlug(boardForm.slug)
                         }`}
                         target="_blank"
                         rel="noopener noreferrer"
                         className="text-indigo-600 dark:text-indigo-400 hover:text-indigo-500 dark:hover:text-indigo-300 underline"
                       >
-                        {getPageUrl(page, settings)}/roadmap/{boardForm.slug}
+                        {getPageUrl(page, settings)}/roadmap/{escapeSlug(boardForm.slug)}
                       </a>
                     </p>
                     {boardForm.is_public && (
EOF
@@ -105,6 +105,15 @@
categories,
initialTab,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
// Ensure the slug is strictly alphanumeric-hyphen for safety
function escapeSlug(slug: string): string {
return (slug || "")
.toLowerCase()
.replace(/[^a-z0-9-]/g, "")
.replace(/-+/g, "-") // collapse multiple hyphens
.replace(/^-|-$/g, ""); // trim hyphens from ends
}

const router = useRouter();
const { supabase, user } = useUserData();
const { settings: clientSettings } = usePageSettings(page_id, false);
@@ -759,13 +768,13 @@
Public URL:{" "}
<a
href={`${getPageUrl(page, settings)}/roadmap/${
boardForm.slug
escapeSlug(boardForm.slug)
}`}
target="_blank"
rel="noopener noreferrer"
className="text-indigo-600 dark:text-indigo-400 hover:text-indigo-500 dark:hover:text-indigo-300 underline"
>
{getPageUrl(page, settings)}/roadmap/{boardForm.slug}
{getPageUrl(page, settings)}/roadmap/{escapeSlug(boardForm.slug)}
</a>
</p>
{boardForm.is_public && (
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants