From 2ab1d915e3a7db329f09332e8b688e4bd405b748 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 14 Aug 2017 17:56:45 +0200 Subject: [PATCH] Use unicode regex in mentions and links. --- lib/pleroma/formatter.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 179c33560..5c19d8f87 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -1,7 +1,7 @@ defmodule Pleroma.Formatter do alias Pleroma.User - @link_regex ~r/https?:\/\/[\w\.\/?=\-#%&]+[\w]/ + @link_regex ~r/https?:\/\/[\w\.\/?=\-#%&]+[\w]/u def linkify(text) do Regex.replace(@link_regex, text, "\\0") end @@ -14,7 +14,7 @@ def parse_tags(text) 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])?)*/ + 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 Regex.scan(regex, text) |> List.flatten