Skip to content
Open
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions modules/playground/components/playground-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ const PlaygroundEditor = ({
.padEnd(6, "0")
: "#30bced";

const sanitizeForCss = (value: string) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

2. Unicode names stripped 🐞 Bug ≡ Correctness

sanitizeForCss strips all characters outside an ASCII allowlist, so many legitimate OAuth display
names (accented/CJK/Cyrillic/emoji) will be partially or fully removed before being rendered in the
cursor label. This can result in empty or misleading collaborator labels in the editor.
Agent Prompt
### Issue description
The current regex-based sanitizer removes non-ASCII characters from display names, which can blank or truncate collaborator labels.

### Issue Context
The value is interpolated into a CSS `content: "${name}";` string.

### Fix Focus Areas
- modules/playground/components/playground-editor.tsx[332-373]

### Suggested fix
- Prefer escaping for a CSS string literal instead of stripping to ASCII:
  - remove/escape control characters and newlines
  - escape backslashes and double quotes (`\\` and `\"`)
- Keep the `textContent` assignment (good) and ensure the resulting string cannot terminate the quoted `content` literal.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

value.replace(/[^a-zA-Z0-9 _\-#.]/g, "");

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
provider.awareness.setLocalStateField("user", {
name: session?.user?.name || "Anonymous",
color: userColor,
Expand All @@ -350,8 +353,8 @@ const PlaygroundEditor = ({

for (const [clientId, state] of states) {
if (state.user) {
const color = state.user.color || "orange";
const name = state.user.name || "Anonymous";
const color = sanitizeForCss(state.user.color || "orange");
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Outdated
const name = sanitizeForCss(state.user.name || "Anonymous");
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

css += `
.yRemoteSelection-${clientId} {
Expand Down Expand Up @@ -388,7 +391,7 @@ const PlaygroundEditor = ({
`;
}
}
styleEl.innerHTML = css;
styleEl.textContent = css;
};

provider.awareness.on("update", handleAwarenessUpdate);
Expand Down