Handle empty terms / tags.
authorRoger Braun <roger@rogerbraun.net>
Wed, 1 Nov 2017 08:33:29 +0000 (09:33 +0100)
committerRoger Braun <roger@rogerbraun.net>
Wed, 1 Nov 2017 08:33:29 +0000 (09:33 +0100)
lib/pleroma/web/ostatus/ostatus.ex
test/fixtures/ostatus_incoming_post_tag.xml

index 1e8b71357400c450340a18644c7becf9c5896211..308e206c580b204854cf939593413a669390664b 100644 (file)
@@ -169,7 +169,9 @@ defmodule Pleroma.Web.OStatus do
 
   def get_tags(entry) do
     :xmerl_xpath.string('//category', entry)
-    |> Enum.map(fn (category) -> string_from_xpath("/category/@term", category) |> String.downcase end)
+    |> Enum.map(fn (category) -> string_from_xpath("/category/@term", category) end)
+    |> Enum.filter(&(&1))
+    |> Enum.map(&String.downcase/1)
   end
 
   def maybe_update(doc, user) do
index 5febb80d1df47add4f83058c38e8bfe0b1f577ca..0f99c41262ff14e566e4ade252cbfc70fbd69b75 100644 (file)
@@ -43,6 +43,7 @@
  <title>New note by lambadalambda</title>
  <content type="html">Will it blend?</content>
  <category term="Nsfw"/>
+ <category term=""/>
  <link rel="alternate" type="text/html" href="https://social.heldscal.la/notice/1967725"/>
  <status_net notice_id="1967725"></status_net>
  <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>