Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/utils/metaTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Meta tag management utilities
export function setMetaTag(name: string, content: string): void {
let el = document.querySelector('meta[name=' + JSON.stringify(name) + ']');
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Building the CSS selector with JSON.stringify(name) is unsafe and can break querySelector for valid string inputs; use CSS escaping for attribute selectors.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/metaTags.ts, line 3:

<comment>Building the CSS selector with `JSON.stringify(name)` is unsafe and can break `querySelector` for valid string inputs; use CSS escaping for attribute selectors.</comment>

<file context>
@@ -0,0 +1,27 @@
+// Meta tag management utilities
+export function setMetaTag(name: string, content: string): void {
+  let el = document.querySelector('meta[name=' + JSON.stringify(name) + ']');
+  if (!el) {
+    el = document.createElement('meta');
</file context>
Fix with Cubic

if (!el) {
el = document.createElement('meta');
el.setAttribute('name', name);
document.head.appendChild(el);
}
el.setAttribute('content', content);
}

export function setOgTag(property: string, content: string): void {
let el = document.querySelector('meta[property=' + JSON.stringify(property) + ']');
if (!el) {
el = document.createElement('meta');
el.setAttribute('property', property);
document.head.appendChild(el);
}
el.setAttribute('content', content);
}

export function setPageMeta(title: string, description: string): void {
document.title = title;
setMetaTag('description', description);
setOgTag('og:title', title);
setOgTag('og:description', description);
}
Loading