From: Roger Braun Date: Sun, 18 Jun 2017 17:04:46 +0000 (+0200) Subject: Downcase tags coming in through the TwAPI. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=6cac8e3c8b866c71e96ade110b7b1e222dd78751;p=akkoma Downcase tags coming in through the TwAPI. --- diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 50c4279f6..a8149b7b3 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -9,7 +9,7 @@ defmodule Pleroma.Formatter do @tag_regex ~r/\#\w+/u def parse_tags(text) do Regex.scan(@tag_regex, text) - |> Enum.map(fn (["#" <> tag = full_tag]) -> {full_tag, tag} end) + |> Enum.map(fn (["#" <> tag = full_tag]) -> {full_tag, String.downcase(tag)} end) end def parse_mentions(text) do diff --git a/test/formatter_test.exs b/test/formatter_test.exs index 35625f8ff..eb4affab8 100644 --- a/test/formatter_test.exs +++ b/test/formatter_test.exs @@ -16,9 +16,9 @@ defmodule Pleroma.FormatterTest do describe ".parse_tags" do test "parses tags in the text" do - text = "Here's a #test. Maybe these are #working or not. What about #漢字? And #は。" + text = "Here's a #Test. Maybe these are #working or not. What about #漢字? And #は。" expected = [ - {"#test", "test"}, + {"#Test", "test"}, {"#working", "working"}, {"#漢字", "漢字"}, {"#は", "は"}