Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix(social-publish): preserve join controls in exact bodies

Barack Sokullua1bd6a84075f
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 8b567b88d..78a1a6e21 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -2345,10 +2345,12 @@ export class Agent extends LoopDetector {
// Same pipeline as _workflowMessageBody, but NFC instead of NFKC: exact
// social-body verification must keep visibly distinct payloads (circled
- // digits, fullwidth letters, ligatures) distinct. Keep the two in sync.
+ // digits, fullwidth letters, ligatures) distinct. Only genuinely ignorable
+ // characters are stripped: zero-width join controls shape visible text
+ // (joined emoji, Indic scripts) and are preserved. Keep the two in sync.
_workflowSocialExactBody(value) {
let text = String(value ?? '')
- .replace(new RegExp('[\\u200b-\\u200d\\ufeff]', 'g'), '')
+ .replace(new RegExp('[\\u200b\\ufeff]', 'g'), '')
.replace(/\r\n?/g, '\n')
.split('\n')
.map(line => line.replace(/\s+/g, ' ').trim())
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 0b67f1994..5aa07e1fc 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -2060,10 +2060,12 @@ export class Agent extends LoopDetector {
// Same pipeline as _workflowMessageBody, but NFC instead of NFKC: exact
// social-body verification must keep visibly distinct payloads (circled
- // digits, fullwidth letters, ligatures) distinct. Keep the two in sync.
+ // digits, fullwidth letters, ligatures) distinct. Only genuinely ignorable
+ // characters are stripped: zero-width join controls shape visible text
+ // (joined emoji, Indic scripts) and are preserved. Keep the two in sync.
_workflowSocialExactBody(value) {
let text = String(value ?? '')
- .replace(new RegExp('[\\u200b-\\u200d\\ufeff]', 'g'), '')
+ .replace(new RegExp('[\\u200b\\ufeff]', 'g'), '')
.replace(/\r\n?/g, '\n')
.split('\n')
.map(line => line.replace(/\s+/g, ' ').trim())
diff --git a/test/run.js b/test/run.js
index 09cb521b7..00a93d430 100644
--- a/test/run.js
+++ b/test/run.js
@@ -91661,6 +91661,14 @@ test('X and Bluesky same-route publication accepts only one new permalink with t
{ field: 'body', value: 'Hello world' },
{ bodyText: 'Hello world' },
), true, AgentClass.name + ': an identical body stopped verifying');
+ assert.equal(agent._workflowSocialPublishedBodyObserved(
+ { field: 'body', value: 'Family: πŸ‘¨πŸ‘©πŸ‘§' },
+ { bodyText: 'Family: πŸ‘¨β€πŸ‘©β€πŸ‘§' },
+ ), false, AgentClass.name + ': a ZWJ-stripped body verified against joined emoji');
+ assert.equal(agent._workflowSocialPublishedBodyObserved(
+ { field: 'body', value: 'Family: πŸ‘¨β€πŸ‘©β€πŸ‘§' },
+ { bodyText: 'Family: πŸ‘¨β€πŸ‘©β€πŸ‘§' },
+ ), true, AgentClass.name + ': joined emoji stopped verifying');
assert.equal(agent._workflowSocialPublishedBodyObserved(
{ field: 'body', value: '1', rawValue: 'β‘ ' },
{ bodyText: '1' },