-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/incoming-poll-emoji' into 'develop'
Fix emoji in Question, force generated context/context_id insertion Closes #1870 See merge request pleroma/pleroma!2915
- Loading branch information
Showing
11 changed files
with
108 additions
and
16 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Pleroma: A lightweight social networking server | ||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> | ||
# SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Emoji do | ||
use Ecto.Type | ||
|
||
def type, do: :map | ||
|
||
def cast(data) when is_map(data) do | ||
has_invalid_emoji? = | ||
Enum.find(data, fn | ||
{name, uri} when is_binary(name) and is_binary(uri) -> | ||
# based on ObjectValidators.Uri.cast() | ||
case URI.parse(uri) do | ||
%URI{host: nil} -> true | ||
%URI{host: ""} -> true | ||
%URI{scheme: scheme} when scheme in ["https", "http"] -> false | ||
_ -> true | ||
end | ||
|
||
{_name, _uri} -> | ||
true | ||
end) | ||
|
||
if has_invalid_emoji?, do: :error, else: {:ok, data} | ||
end | ||
|
||
def cast(_data), do: :error | ||
|
||
def dump(data), do: {:ok, data} | ||
|
||
def load(data), do: {:ok, data} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters