Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: reject malformed X post status identifiers

[._.]/ Adam Eivy8c8061e07a2f
diff --git a/server/lib/xPostMedia.js b/server/lib/xPostMedia.js
index 6956638968..13e148205d 100644
--- a/server/lib/xPostMedia.js
+++ b/server/lib/xPostMedia.js
@@ -48,7 +48,7 @@ export function parseXPostUrl(input) {
if (!isXHost(u.hostname)) {
throw badUrl('That doesn’t look like an x.com/twitter.com post URL');
}
- const match = u.pathname.match(/^\/[^/]+\/status\/(\d+)/);
+ const match = u.pathname.match(/^\/[^/]+\/status\/(\d+)(?:\/|$)/);
if (!match) {
throw badUrl('Include the full post URL, e.g. x.com/user/status/1234567890');
}
diff --git a/server/lib/xPostMedia.test.js b/server/lib/xPostMedia.test.js
index 721d96b56e..2412b04f4e 100644
--- a/server/lib/xPostMedia.test.js
+++ b/server/lib/xPostMedia.test.js
@@ -42,6 +42,11 @@ describe('parseXPostUrl', () => {
expect(() => parseXPostUrl('https://x.com/i/lists/1')).toThrow(/full post url/i);
});
+ it('rejects status ids with non-path suffixes', () => {
+ expect(() => parseXPostUrl('https://x.com/someuser/status/42junk')).toThrow(/full post url/i);
+ expect(() => parseXPostUrl('https://x.com/someuser/status/42.1')).toThrow(/full post url/i);
+ });
+
it('every ServerError carries the same error code', () => {
for (const bad of ['', 'ftp://x.com/user/status/1', 'https://example.com/user/status/1', 'https://x.com/user']) {
try {