aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2021-01-21 20:50:06 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2021-01-21 20:50:06 +0300
commitca7f24064304945587fc232325dce4b834ff6c94 (patch)
tree31171deea02798d4c8dee2c6652833f3d50e3409
parentc041e9c6300726a40a00146bba04d3ec752219d9 (diff)
downloadpleroma-ca7f24064304945587fc232325dce4b834ff6c94.tar.gz
[#3213] Ignoring of blank elements from objects.data->tag.
-rw-r--r--lib/pleroma/object.ex2
-rw-r--r--test/pleroma/hashtag_test.exs17
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index 5102be1de..9b5c1bec1 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -420,6 +420,8 @@ defmodule Pleroma.Object do
hashtag when is_bitstring(hashtag) -> String.downcase(hashtag)
end)
|> Enum.uniq()
+ # Note: "" elements (plain text) might occur in `data.tag` for incoming objects
+ |> Enum.filter(&(&1 not in [nil, ""]))
end
def object_data_hashtags(_), do: []
diff --git a/test/pleroma/hashtag_test.exs b/test/pleroma/hashtag_test.exs
new file mode 100644
index 000000000..0264dea0b
--- /dev/null
+++ b/test/pleroma/hashtag_test.exs
@@ -0,0 +1,17 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.HashtagTest do
+ use Pleroma.DataCase
+
+ alias Pleroma.Hashtag
+
+ describe "changeset validations" do
+ test "ensure non-blank :name" do
+ changeset = Hashtag.changeset(%Hashtag{}, %{name: ""})
+
+ assert {:name, {"can't be blank", [validation: :required]}} in changeset.errors
+ end
+ end
+end