From 7214d574630842e4efb76d6c3494a180cbc2a930 Mon Sep 17 00:00:00 2001 From: href Date: Wed, 12 Dec 2018 21:44:08 +0100 Subject: [PATCH] Extended nicknames: allow dashes. --- config/config.md | 2 +- lib/pleroma/formatter.ex | 2 +- lib/pleroma/user.ex | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.md b/config/config.md index e8e2cf6f8..6b45c01da 100644 --- a/config/config.md +++ b/config/config.md @@ -63,7 +63,7 @@ This filter replaces the filename (not the path) of an upload. For complete obfu * "masto": Copy verbatim, as in Mastodon. * "noop": Don't copy the subject. * `always_show_subject_input`: When set to false, auto-hide the subject field when it's empty. -* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscore). This will break federation with +* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscores/dashes). This will break federation with older software for theses nicknames. ## :fe diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 1fea1c57a..133683794 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -18,7 +18,7 @@ defmodule Pleroma.Formatter do def parse_mentions(text) do # Modified from https://www.w3.org/TR/html5/forms.html#valid-e-mail-address regex = - ~r/@[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]*@?[a-zA-Z0-9_](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/u + ~r/@[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]*@?[a-zA-Z0-9_-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/u Regex.scan(regex, text) |> List.flatten() diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index f10cdfbc8..49928bc13 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -14,7 +14,7 @@ defmodule Pleroma.User do @email_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ @strict_local_nickname_regex ~r/^[a-zA-Z\d]+$/ - @extended_local_nickname_regex ~r/^[a-zA-Z\d_]+$/ + @extended_local_nickname_regex ~r/^[a-zA-Z\d_-]+$/ schema "users" do field(:bio, :string)