The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): put a bot's name into its face as text, never as markup
emozilla24a5817eae20
diff --git a/apps/desktop/src/plugins/hermes-bots/avatar.test.tsx b/apps/desktop/src/plugins/hermes-bots/avatar.test.tsxindex e7fa5aab33d..72d5977ef6e 100644--- a/apps/desktop/src/plugins/hermes-bots/avatar.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/avatar.test.tsx@@ -120,6 +120,23 @@ describe('rendering a blob face', () => {expect('traits' in opts).toBe(false)})+ it('keeps any bot name inside the data-bot-face attribute as text', async () => {+ // A name is text, not markup: quotes and angle brackets in it close neither the attribute nor+ // the svg tag, and replacement patterns such as `$&` stay literal. The roster PNG backfill+ // still finds the face by the exact name.+ const { BotFace } = await import('./avatar')++ for (const name of ['x"><img src=x onerror="globalThis.botFaceRan=1"><b title="', 'a$&b$\'c']) {+ const { container, unmount } = render(<BotFace color="#38bdf8" name={name} shape="blobatar" size={56} />)++ expect(container.querySelector('img')).toBeNull()+ expect(container.querySelector('b')).toBeNull()+ expect(container.querySelectorAll('svg')).toHaveLength(1)+ expect(container.querySelector('svg')?.getAttribute('data-bot-face')).toBe(name)+ unmount()+ }+ })+it('puts every silhouette inside its own frozen band', async () => {const { BLOB_KINDS, BotFace } = await import('./avatar')diff --git a/apps/desktop/src/plugins/hermes-bots/avatar.tsx b/apps/desktop/src/plugins/hermes-bots/avatar.tsxindex addaaa6ae80..c4e0cea5ec3 100644--- a/apps/desktop/src/plugins/hermes-bots/avatar.tsx+++ b/apps/desktop/src/plugins/hermes-bots/avatar.tsx@@ -189,6 +189,11 @@ export function blobShapeString(seedPart: string, kind: string) {return seedPart ? `blobatar:${seedPart}` : 'blobatar'}+/** *text* as an HTML attribute value: no quote or angle bracket in it ends the attribute or the tag. */+function attributeText(text: string): string {+ return text.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>')+}+/** Static SVG markup for a blob face, tagged data-bot-face so the roster's* PNG backfill (pushLocalAvatars → rasterizeSvgToPng) still finds it. */function blobMarkup(shape: null | string | undefined, name: string, size: number) {@@ -209,7 +214,8 @@ function blobMarkup(shape: null | string | undefined, name: string, size: number}try {- return blobatarSvg(seed, opts).replace('<svg ', '<svg data-bot-face=' + JSON.stringify(name) + ' ')+ // The name goes in as escaped text, through a replacer so `$&`-style patterns in it stay literal.+ return blobatarSvg(seed, opts).replace('<svg ', () => `<svg data-bot-face="${attributeText(name)}" `)} catch {return null}