fix(ui): shorten Freenet URLs in reply previews - #611
Open
skandragon wants to merge 1 commit into
Open
Conversation
The reply-quote strip renders plain text via strip_markdown, which showed the sender's raw gateway URL where the message body already renders a freenet:<id-prefix> label.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replies quoted the sender's raw gateway URL (
http://127.0.0.1:7509/v1/contract/web/<id>/...) where the message body already renders the shortfreenet:<id-prefix>label.The body path goes through
finalize_anchors; the reply-quote strip is plain text and goes throughstrip_markdown→collect_mdast_text, which had noNode::Linkarm. Adding one there covers all three preview call sites at once — the rendered reply strip (:381) and the two composer previews (:5313,:5384).Label-only: the strip has no href, so there is nothing to host-rewrite there.
[label](url)text is left alone, mirroring the body's "visible text equals href" rule.Not parity with the body, deliberately
finalize_anchorscompares scraped HTML anchor text against the href after markdown'ssanitize_uripercent-encoding; this arm compares raw mdast on both sides. A URL whose suffix markdown percent-encodes (non-ASCII,^,|) therefore shortens in the preview but not in the body. One-way superset, and harmless — the preview is a non-clickable text node, so the worst case is a shortened label where the body kept the full URL, never the reverse. Documented at the arm.Tests
clean_reply_preview_shortens_bare_freenet_urlscovers: bare URL with path suffix, non-loopback host, trailing-slash normalisation, non-Freenet link passthrough, explicit[label](url), and a spoof URL that only mentions the marker in its query. Mutation-checked — removing the arm reddens two assertions, inverting the guard reddens three.cargo test -p river-ui --bins: 892 passed.Known gaps, all pre-existing and left alone
- <url>\n- x→freenet:UDzGbcWrx). The raw URL ran into the next item too; the label just makes it misleading rather than ugly. Fix belongs in theParagraph/ListItempath.Node::Imagealt text is dropped entirely.No contract/delegate/common changes — no migration or redeploy needed.