Repository navigation
A received link preview shows only if its https link is in the message - #168
Conversation
A sender could attach a card whose link isn't in the text (it says one site, opens another). Signal's apps drop such previews; the projector now does too, for received messages and those sent from the phone. The message itself still shows.
…oves the link removes the card The card's link was matched anywhere in the text, so part of a longer link counted (github.co inside github.com/..., a link inside another's query or fragment). It now must be a whole link: a word, or one in opening brackets or quotes, starts with it and only closing punctuation follows. Links with a name before the host are refused, and a view-once caption, which isn't kept, gives no card. An edit whose text no longer has the card's link drops the card and its image.
|
Review findings and fixes (commit e2a7f1a): Critical 1: a match anywhere in the text let part of a link count ( Important 2: an edit kept the old card. Important 3: test gaps. All added to the projector test:
Suggestions taken:
Declined, for the owner:
Checks: |
What changed
link_preview::previewable(text, url)(next tofirst_link) decides whether a preview gets a card. Its URL must:([<"'), starts with it, and only closing or sentence punctuation (.,;:!?)]>"') follows it in that word.data_message(projector.rs) keeps a preview only if it passes that check, against the text as stored. Received messages and sent-from-phone transcripts both go throughdata_message. A view-once caption isn't kept, so a view-once message gets no card. A preview that fails the check is dropped; the message and its files stay.Op::Editindb.rs) whose new text no longer passes the check for the stored card's URL drops the card and its image (the attachment row at position -1 and its file). Without this, an edit could keep a card for a link the new text no longer has.Why
A sender could attach a preview card whose link isn't in the message: the card says "Google Docs", the link opens something else, and only a small host name gives it away. Signal's apps keep a received preview only if its URL is one of the links they find in the message text. The link-previews spec (
docs/superpowers/specs/2026-10-17-m4-link-previews-design.md) already says recipients show it only when its URL is in the text. A match anywhere in the text isn't enough:https://github.cosits insidehttps://github.com/acme/repo, and one link can sit inside another's query or fragment. So the URL must be a whole link.Other paths:
history/import.rs) takes previews the phone has already filtered.core/desktop) doesn't show link previews.presage.db) still holds the original preview, but the app shows only the projection, so that copy isn't touched.client.rssend_text,body.contains(&p.url)) is unchanged. The draft's URL comes from our ownfirst_link, which also finds a link in the middle of a word (see:https://…). The stricter rule there would drop cards the composer had shown, and our own text isn't the threat.How it was tested
a_preview_is_kept_only_if_its_https_link_is_in_the_message_whole(projector) runs each case as a received message and as a phone transcript.look: https://example.org.;(https://en.wikipedia.org/wiki/Rust_(language))with or without the final)in the URL.github.coinsidegithub.com/…;accounts.google.cominsideaccounts.google.com.au/…; a link in another's fragment; a link in another's?q=; http; an unparseablehttps://;https://[email protected]/….an_edit_without_the_cards_link_drops_the_card_and_its_image(db): an edit that keeps the link keeps the card. One that changes it drops the card, and the downloaded image file goes.github.cowith the first, match-anywhere version.attachments_and_previews_come_with_their_message: its body was"look", without the preview's link. It now includes the link.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo test(sig-core: 480 passed, 3 ignored; the rest pass) all pass.Closes #162