ChatMessage: Correctly ingest emoji tags.
This commit is contained in:
parent
ec7335535d
commit
1e28d34592
@ -9,6 +9,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator do
|
|||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.Types
|
alias Pleroma.Web.ActivityPub.ObjectValidators.Types
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
import Pleroma.Web.ActivityPub.Transmogrifier, only: [fix_emoji: 1]
|
||||||
|
|
||||||
@primary_key false
|
@primary_key false
|
||||||
@derive Jason.Encoder
|
@derive Jason.Encoder
|
||||||
@ -42,6 +43,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator do
|
|||||||
|
|
||||||
def fix(data) do
|
def fix(data) do
|
||||||
data
|
data
|
||||||
|
|> fix_emoji()
|
||||||
|> Map.put_new("actor", data["attributedTo"])
|
|> Map.put_new("actor", data["attributedTo"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
12
test/fixtures/create-chat-message.json
vendored
12
test/fixtures/create-chat-message.json
vendored
@ -9,6 +9,18 @@
|
|||||||
"to": [
|
"to": [
|
||||||
"http://2hu.gensokyo/users/marisa"
|
"http://2hu.gensokyo/users/marisa"
|
||||||
],
|
],
|
||||||
|
"tag": [
|
||||||
|
{
|
||||||
|
"icon": {
|
||||||
|
"type": "Image",
|
||||||
|
"url": "http://2hu.gensokyo/emoji/Firefox.gif"
|
||||||
|
},
|
||||||
|
"id": "http://2hu.gensokyo/emoji/Firefox.gif",
|
||||||
|
"name": ":firefox:",
|
||||||
|
"type": "Emoji",
|
||||||
|
"updated": "1970-01-01T00:00:00Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
"type": "ChatMessage"
|
"type": "ChatMessage"
|
||||||
},
|
},
|
||||||
"published": "2018-02-12T14:08:20Z",
|
"published": "2018-02-12T14:08:20Z",
|
||||||
|
@ -75,6 +75,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
|
|||||||
|
|
||||||
assert object
|
assert object
|
||||||
assert object.data["content"] == "You expected a cute girl? Too bad. alert('XSS')"
|
assert object.data["content"] == "You expected a cute girl? Too bad. alert('XSS')"
|
||||||
|
assert match?(%{"firefox" => _}, object.data["emoji"])
|
||||||
|
|
||||||
refute Chat.get(author.id, recipient.ap_id)
|
refute Chat.get(author.id, recipient.ap_id)
|
||||||
assert Chat.get(recipient.id, author.ap_id)
|
assert Chat.get(recipient.id, author.ap_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user