Skip to content

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

fix(social-publish): keep numeric-alt images out of emoji filter

Barack Sokullu6dda7ea09698
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index e8f47cf0b..c84eddec2 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -33528,7 +33528,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const src = String(node.getAttribute?.('src') || node.src || '').toLowerCase();
if (src.includes('profile_images') || src.includes('/avatar/') || src.includes('/emoji/') || src.includes('twemoji')) return true;
const alt = String(node.getAttribute?.('alt') || '');
- if (/^\\p{Emoji}+$/u.test(alt)) return true;
+ // Digits (and "#" / "*") carry the Emoji property as keycap
+ // bases, so a numeric-only alt such as "1" must not read as
+ // an emoji: only discard the node when some other Emoji
+ // character is present. This probe is injected through a
+ // template literal, so backslashes are doubled here.
+ if (/^(?=[\\s\\S]*[^\\d\\s#*])\\p{Emoji}+$/u.test(alt)) return true;
} catch {}
return false;
};
diff --git a/src/chrome/src/agent/completion-invariant.js b/src/chrome/src/agent/completion-invariant.js
index 26f2f8632..5952b4da6 100644
--- a/src/chrome/src/agent/completion-invariant.js
+++ b/src/chrome/src/agent/completion-invariant.js
@@ -389,7 +389,10 @@ export function publicationResourceRecordRoot(link, identity, publicationResourc
const src = String(node.getAttribute?.('src') || node.src || '').toLowerCase();
if (src.includes('profile_images') || src.includes('/avatar/') || src.includes('/emoji/') || src.includes('twemoji')) return true;
const alt = String(node.getAttribute?.('alt') || '');
- if (/^\p{Emoji}+$/u.test(alt)) return true;
+ // Digits (and "#" / "*") carry the Emoji property as keycap bases,
+ // so a numeric-only alt such as "1" must not read as an emoji: only
+ // discard the node when some other Emoji character is present.
+ if (/^(?=[\s\S]*[^\d\s#*])\p{Emoji}+$/u.test(alt)) return true;
} catch {}
return false;
};
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 3b7fdfa2a..3340a1cd3 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -30007,7 +30007,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const src = String(node.getAttribute?.('src') || node.src || '').toLowerCase();
if (src.includes('profile_images') || src.includes('/avatar/') || src.includes('/emoji/') || src.includes('twemoji')) return true;
const alt = String(node.getAttribute?.('alt') || '');
- if (/^\\p{Emoji}+$/u.test(alt)) return true;
+ // Digits (and "#" / "*") carry the Emoji property as keycap
+ // bases, so a numeric-only alt such as "1" must not read as
+ // an emoji: only discard the node when some other Emoji
+ // character is present. This probe is injected through a
+ // template literal, so backslashes are doubled here.
+ if (/^(?=[\\s\\S]*[^\\d\\s#*])\\p{Emoji}+$/u.test(alt)) return true;
} catch {}
return false;
};
diff --git a/src/firefox/src/agent/completion-invariant.js b/src/firefox/src/agent/completion-invariant.js
index 26f2f8632..5952b4da6 100644
--- a/src/firefox/src/agent/completion-invariant.js
+++ b/src/firefox/src/agent/completion-invariant.js
@@ -389,7 +389,10 @@ export function publicationResourceRecordRoot(link, identity, publicationResourc
const src = String(node.getAttribute?.('src') || node.src || '').toLowerCase();
if (src.includes('profile_images') || src.includes('/avatar/') || src.includes('/emoji/') || src.includes('twemoji')) return true;
const alt = String(node.getAttribute?.('alt') || '');
- if (/^\p{Emoji}+$/u.test(alt)) return true;
+ // Digits (and "#" / "*") carry the Emoji property as keycap bases,
+ // so a numeric-only alt such as "1" must not read as an emoji: only
+ // discard the node when some other Emoji character is present.
+ if (/^(?=[\s\S]*[^\d\s#*])\p{Emoji}+$/u.test(alt)) return true;
} catch {}
return false;
};
diff --git a/test/run.js b/test/run.js
index 073022adf..0b104b557 100644
--- a/test/run.js
+++ b/test/run.js
@@ -25599,6 +25599,11 @@ test('publication resource records keep the owning social card when it embeds an
getAttribute: name => (name === 'data-testid' ? 'tweetPhoto' : (name === 'src' ? 'https://pbs.twimg.com/media/pic.jpg' : null)),
closest: () => null,
};
+ const numericAltPhotoNode = {
+ tagName: 'img',
+ getAttribute: name => (name === 'alt' ? '2026' : (name === 'src' ? 'https://pbs.twimg.com/media/pic2.jpg' : null)),
+ closest: () => null,
+ };
const linkPreviewNode = {
tagName: 'img',
getAttribute: name => (name === 'src' ? 'https://pbs.twimg.com/card_img/thumb.jpg' : null),
@@ -25621,11 +25626,11 @@ test('publication resource records keep the owning social card when it embeds an
querySelectorAll: selector => {
const s = String(selector);
if (s.includes('img') || s.includes('video') || s.includes('tweetPhoto')) {
- return [avatarNode, emojiNode, linkPreviewNode, photoNode, videoComponentNode, videoNode];
+ return [avatarNode, emojiNode, linkPreviewNode, photoNode, numericAltPhotoNode, videoComponentNode, videoNode];
}
return [plainPermalink];
},
- contains: node => [plainPermalink, mediaCard, avatarNode, emojiNode, linkPreviewNode, photoNode, videoComponentNode, videoNode].includes(node),
+ contains: node => [plainPermalink, mediaCard, avatarNode, emojiNode, linkPreviewNode, photoNode, numericAltPhotoNode, videoComponentNode, videoNode].includes(node),
};
const mediaPermalink = {
...plainPermalink,
@@ -25633,7 +25638,7 @@ test('publication resource records keep the owning social card when it embeds an
};
const mediaRecord = invariant.publicationResourceRecordRoot(mediaPermalink, identity, identityOf);
assert.equal(mediaRecord.root, mediaCard);
- assert.deepEqual(mediaRecord.attachments, [photoNode, videoComponentNode],
+ assert.deepEqual(mediaRecord.attachments, [photoNode, numericAltPhotoNode, videoComponentNode],
`${label}: media attachments failed to deduplicate nested videoNode or failed to include photo`);
// A Bluesky external link card names no card container: its thumbnail sits