Fix mentioning complex usernames
All checks were successful
ci/woodpecker/pr/test/2 Pipeline was successful
ci/woodpecker/pr/test/1 Pipeline was successful

The updated linkify is much more liberal about usernames in mentions.

Fixes: #1011
This commit is contained in:
Oneric 2025-11-18 00:00:00 +00:00
commit 810e3b1201
3 changed files with 41 additions and 2 deletions

View file

@ -161,7 +161,7 @@ defmodule Pleroma.Mixfile do
{:floki, "~> 0.34"},
{:timex, "~> 3.7"},
{:ueberauth, "~> 0.10.7"},
{:linkify, "~> 0.5.3"},
{:linkify, git: "https://akkoma.dev/AkkomaGang/linkify.git", branch: "main"},
{:http_signatures,
git: "https://akkoma.dev/AkkomaGang/http_signatures.git", branch: "main"},
{:telemetry, "~> 1.2"},

View file

@ -69,7 +69,7 @@
"joken": {:hex, :joken, "2.6.2", "5daaf82259ca603af4f0b065475099ada1b2b849ff140ccd37f4b6828ca6892a", [:mix], [{:jose, "~> 1.11.10", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm", "5134b5b0a6e37494e46dbf9e4dad53808e5e787904b7c73972651b51cce3d72b"},
"jose": {:hex, :jose, "1.11.10", "a903f5227417bd2a08c8a00a0cbcc458118be84480955e8d251297a425723f83", [:mix, :rebar3], [], "hexpm", "0d6cd36ff8ba174db29148fc112b5842186b68a90ce9fc2b3ec3afe76593e614"},
"jumper": {:hex, :jumper, "1.0.2", "68cdcd84472a00ac596b4e6459a41b3062d4427cbd4f1e8c8793c5b54f1406a7", [:mix], [], "hexpm", "9b7782409021e01ab3c08270e26f36eb62976a38c1aa64b2eaf6348422f165e1"},
"linkify": {:hex, :linkify, "0.5.3", "5f8143d8f61f5ff08d3aeeff47ef6509492b4948d8f08007fbf66e4d2246a7f2", [:mix], [], "hexpm", "3ef35a1377d47c25506e07c1c005ea9d38d700699d92ee92825f024434258177"},
"linkify": {:git, "https://akkoma.dev/AkkomaGang/linkify.git", "b8399ccd74849b70609fe92eea96654c1c36aa6d", [branch: "main"]},
"mail": {:hex, :mail, "0.5.1", "6383a61620aea24675c96e34b9019dede1bfc9a37ee10ce5a5cafcc7c5e48743", [:mix], [], "hexpm", "595144340b74f23d651ea2b4a72a896819940478d7425dfa302ea3b5c9041ec9"},
"majic": {:git, "https://akkoma.dev/AkkomaGang/majic.git", "80540b36939ec83f48e76c61e5000e0fd67706f0", [branch: "main"]},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},

View file

@ -0,0 +1,39 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.ActivityDraftTest do
alias Pleroma.Web.CommonAPI.ActivityDraft
use Pleroma.DataCase
import Pleroma.Factory
setup do
user = insert(:user, local: true)
%{user: user}
end
defp test_dm_addressing(from, to) do
{:ok, draft} =
ActivityDraft.create(from, %{
status: "@#{to.nickname} hi",
visibility: "direct"
})
assert to.ap_id in draft.mentions
end
describe "addresses mentioned user" do
test "when no dot in name", %{user: user} do
addr = insert(:user, local: false, nickname: "nix@example.org")
test_dm_addressing(user, addr)
end
test "when dot in name", %{user: user} do
addr = insert(:user, local: false, nickname: "ly.nx@example.org")
test_dm_addressing(user, addr)
end
end
end