summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml68
-rw-r--r--.gitlab/merge_request_templates/Default.md10
-rw-r--r--changelog.d/3873.fix1
-rw-r--r--changelog.d/3878.skip0
-rw-r--r--changelog.d/3882.add1
-rw-r--r--changelog.d/3883.fix1
-rw-r--r--changelog.d/changelog-improve.skip0
-rw-r--r--docs/development/API/admin_api.md2
-rw-r--r--lib/pleroma/object/fetcher.ex86
-rw-r--r--lib/pleroma/object/updater.ex48
-rw-r--r--lib/pleroma/web/activity_pub/side_effects.ex36
-rw-r--r--lib/pleroma/web/admin_api/controllers/frontend_controller.ex25
-rw-r--r--lib/pleroma/web/admin_api/views/frontend_view.ex3
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex5
-rw-r--r--lib/pleroma/web/plugs/uploaded_media.ex4
-rw-r--r--priv/scrubbers/default.ex81
-rw-r--r--test/pleroma/object/fetcher_test.exs84
-rw-r--r--test/pleroma/web/admin_api/controllers/frontend_controller_test.exs1
-rw-r--r--test/pleroma/web/common_api_test.exs11
-rw-r--r--test/pleroma/web/plugs/uploaded_media_plug_test.exs4
-rw-r--r--tools/check-changelog26
21 files changed, 278 insertions, 219 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 72ac4981d..8daa9f434 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,31 +45,39 @@ check-changelog:
stage: check-changelog
image: alpine
rules:
+ - if: $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH == 'pleroma/pleroma' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'weblate-extract'
+ when: never
+ - if: $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH == 'pleroma/pleroma' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'weblate'
+ when: never
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
before_script: ''
after_script: ''
cache: {}
script:
+ - apk add git
- sh ./tools/check-changelog
+.build_changes_policy:
+ rules:
+ - changes:
+ - ".gitlab-ci.yml"
+ - "**/*.ex"
+ - "**/*.exs"
+ - "mix.lock"
+
build:
+ extends: .build_changes_policy
stage: build
- only:
- changes: &build_changes_policy
- - ".gitlab-ci.yml"
- - "**/*.ex"
- - "**/*.exs"
- - "mix.lock"
script:
- mix compile --force
spec-build:
stage: test
- only:
- changes:
- - ".gitlab-ci.yml"
- - "lib/pleroma/web/api_spec/**/*.ex"
- - "lib/pleroma/web/api_spec.ex"
+ rules:
+ - changes:
+ - ".gitlab-ci.yml"
+ - "lib/pleroma/web/api_spec/**/*.ex"
+ - "lib/pleroma/web/api_spec.ex"
artifacts:
paths:
- spec.json
@@ -91,9 +99,8 @@ benchmark:
- mix pleroma.load_testing
unit-testing:
+ extends: .build_changes_policy
stage: test
- only:
- changes: *build_changes_policy
cache: &testing_cache_policy
<<: *global_cache_policy
policy: pull
@@ -114,11 +121,10 @@ unit-testing:
path: coverage.xml
unit-testing-erratic:
+ extends: .build_changes_policy
stage: test
retry: 2
allow_failure: true
- only:
- changes: *build_changes_policy
cache: &testing_cache_policy
<<: *global_cache_policy
policy: pull
@@ -149,9 +155,8 @@ unit-testing-erratic:
# - mix test --trace --only federated
unit-testing-rum:
+ extends: .build_changes_policy
stage: test
- only:
- changes: *build_changes_policy
cache: *testing_cache_policy
services:
- name: minibikini/postgres-with-rum:12
@@ -167,10 +172,9 @@ unit-testing-rum:
- mix test --preload-modules
lint:
+ extends: .build_changes_policy
image: &current_elixir elixir:1.12-alpine
stage: test
- only:
- changes: *build_changes_policy
cache: *testing_cache_policy
before_script: &current_bfr_script
- apk update
@@ -182,18 +186,16 @@ lint:
- mix format --check-formatted
analysis:
+ extends: .build_changes_policy
stage: test
- only:
- changes: *build_changes_policy
cache: *testing_cache_policy
script:
- mix credo --strict --only=warnings,todo,fixme,consistency,readability
cycles:
+ extends: .build_changes_policy
image: *current_elixir
stage: test
- only:
- changes: *build_changes_policy
cache: {}
before_script: *current_bfr_script
script:
@@ -381,14 +383,6 @@ arm64-musl:
entrypoint: [""]
cache: {}
dependencies: []
- needs:
- - spec-build
- - unit-testing
- - unit-testing-erratic
- - unit-testing-rum
- - lint
- - analysis
- - cycles
before_script: &before-kaniko
- export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
- export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
@@ -517,10 +511,6 @@ docker-combine:latest:
extends: .docker-combine
only:
- develop@pleroma/pleroma
- needs:
- - 'kaniko-latest:linux/amd64'
- - 'kaniko-latest:linux/arm64'
- - 'kaniko-latest:linux/arm'
script:
- 'docker manifest create $IMAGE_TAG $IMAGES'
- 'docker manifest push $IMAGE_TAG'
@@ -533,10 +523,6 @@ docker-combine:stable:
extends: .docker-combine
only:
- stable@pleroma/pleroma
- needs:
- - 'kaniko-stable:linux/amd64'
- - 'kaniko-stable:linux/arm64'
- - 'kaniko-stable:linux/arm'
script:
- 'docker manifest create $IMAGE_TAG $IMAGES'
- 'docker manifest push $IMAGE_TAG'
@@ -549,10 +535,6 @@ docker-combine:release:
extends: .docker-combine
only:
- /^release/.*$/@pleroma/pleroma
- needs:
- - 'kaniko-release:linux/amd64'
- - 'kaniko-release:linux/arm64'
- - 'kaniko-release:linux/arm'
script:
- 'docker manifest create $IMAGE_TAG $IMAGES'
- 'docker manifest push $IMAGE_TAG'
diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md
new file mode 100644
index 000000000..fdf219f99
--- /dev/null
+++ b/.gitlab/merge_request_templates/Default.md
@@ -0,0 +1,10 @@
+### Checklist
+- [ ] Adding a changelog: In the `changelog.d` directory, create a file named `<code>.<type>`.
+
+ `<code>` can be anything, but we recommend using a more or less unique identifier to avoid collisions, such as the branch name.
+
+ `<type>` can be `add`, `remove`, `fix`, `security` or `skip`. `skip` is only used if there is no user-visible change in the MR (for example, only editing comments in the code). Otherwise, choose a type that corresponds to your change.
+
+ In the file, write the changelog entry. For example, if an MR adds group functionality, we can create a file named `group.add` and write `Add group functionality` in it.
+
+ If one changelog entry is not enough, you may add more. But that might mean you can split it into two MRs. Only use more than one changelog entry if you really need to (for example, when one change in the code fix two different bugs, or when refactoring).
diff --git a/changelog.d/3873.fix b/changelog.d/3873.fix
new file mode 100644
index 000000000..4699f7b58
--- /dev/null
+++ b/changelog.d/3873.fix
@@ -0,0 +1 @@
+UploadedMedia: Add missing disposition_type to Content-Disposition \ No newline at end of file
diff --git a/changelog.d/3878.skip b/changelog.d/3878.skip
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/changelog.d/3878.skip
diff --git a/changelog.d/3882.add b/changelog.d/3882.add
new file mode 100644
index 000000000..4712de1dc
--- /dev/null
+++ b/changelog.d/3882.add
@@ -0,0 +1 @@
+Allow lang attribute in status text
diff --git a/changelog.d/3883.fix b/changelog.d/3883.fix
new file mode 100644
index 000000000..6824f2013
--- /dev/null
+++ b/changelog.d/3883.fix
@@ -0,0 +1 @@
+Fix abnormal behaviour when refetching a poll
diff --git a/changelog.d/changelog-improve.skip b/changelog.d/changelog-improve.skip
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/changelog.d/changelog-improve.skip
diff --git a/docs/development/API/admin_api.md b/docs/development/API/admin_api.md
index f6e9f7d2a..7d31ee262 100644
--- a/docs/development/API/admin_api.md
+++ b/docs/development/API/admin_api.md
@@ -1585,6 +1585,7 @@ Returns the content of the document
"build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
"git": "https://git.pleroma.social/pleroma/fedi-fe",
"installed": true,
+ "installed_refs": ["master"],
"name": "fedi-fe",
"ref": "master"
},
@@ -1592,6 +1593,7 @@ Returns the content of the document
"build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
"git": "https://git.pleroma.social/lambadalambda/kenoma",
"installed": false,
+ "installed_refs": [],
"name": "kenoma",
"ref": "master"
}
diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex
index a9a9eeeed..cc3772563 100644
--- a/lib/pleroma/object/fetcher.ex
+++ b/lib/pleroma/object/fetcher.ex
@@ -8,77 +8,30 @@ defmodule Pleroma.Object.Fetcher do
alias Pleroma.Maps
alias Pleroma.Object
alias Pleroma.Object.Containment
- alias Pleroma.Repo
alias Pleroma.Signature
alias Pleroma.Web.ActivityPub.InternalFetchActor
+ alias Pleroma.Web.ActivityPub.MRF
alias Pleroma.Web.ActivityPub.ObjectValidator
+ alias Pleroma.Web.ActivityPub.Pipeline
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.Federator
require Logger
require Pleroma.Constants
- defp touch_changeset(changeset) do
- updated_at =
- NaiveDateTime.utc_now()
- |> NaiveDateTime.truncate(:second)
-
- Ecto.Changeset.put_change(changeset, :updated_at, updated_at)
- end
-
- defp maybe_reinject_internal_fields(%{data: %{} = old_data}, new_data) do
- has_history? = fn
- %{"formerRepresentations" => %{"orderedItems" => list}} when is_list(list) -> true
- _ -> false
- end
-
- internal_fields = Map.take(old_data, Pleroma.Constants.object_internal_fields())
-
- remote_history_exists? = has_history?.(new_data)
-
- # If the remote history exists, we treat that as the only source of truth.
- new_data =
- if has_history?.(old_data) and not remote_history_exists? do
- Map.put(new_data, "formerRepresentations", old_data["formerRepresentations"])
- else
- new_data
- end
-
- # If the remote does not have history information, we need to manage it ourselves
- new_data =
- if not remote_history_exists? do
- changed? =
- Pleroma.Constants.status_updatable_fields()
- |> Enum.any?(fn field -> Map.get(old_data, field) != Map.get(new_data, field) end)
-
- %{updated_object: updated_object} =
- new_data
- |> Object.Updater.maybe_update_history(old_data,
- updated: changed?,
- use_history_in_new_object?: false
- )
-
- updated_object
- else
- new_data
- end
-
- Map.merge(new_data, internal_fields)
- end
-
- defp maybe_reinject_internal_fields(_, new_data), do: new_data
-
@spec reinject_object(struct(), map()) :: {:ok, Object.t()} | {:error, any()}
- defp reinject_object(%Object{data: %{"type" => "Question"}} = object, new_data) do
+ defp reinject_object(%Object{data: %{}} = object, new_data) do
Logger.debug("Reinjecting object #{new_data["id"]}")
- with data <- maybe_reinject_internal_fields(object, new_data),
- {:ok, data, _} <- ObjectValidator.validate(data, %{}),
- changeset <- Object.change(object, %{data: data}),
- changeset <- touch_changeset(changeset),
- {:ok, object} <- Repo.insert_or_update(changeset),
- {:ok, object} <- Object.set_cache(object) do
- {:ok, object}
+ with {:ok, new_data, _} <- ObjectValidator.validate(new_data, %{}),
+ {:ok, new_data} <- MRF.filter(new_data),
+ {:ok, new_object, _} <-
+ Object.Updater.do_update_and_invalidate_cache(
+ object,
+ new_data,
+ _touch_changeset? = true
+ ) do
+ {:ok, new_object}
else
e ->
Logger.error("Error while processing object: #{inspect(e)}")
@@ -86,20 +39,11 @@ defmodule Pleroma.Object.Fetcher do
end
end
- defp reinject_object(%Object{} = object, new_data) do
- Logger.debug("Reinjecting object #{new_data["id"]}")
-
- with new_data <- Transmogrifier.fix_object(new_data),
- data <- maybe_reinject_internal_fields(object, new_data),
- changeset <- Object.change(object, %{data: data}),
- changeset <- touch_changeset(changeset),
- {:ok, object} <- Repo.insert_or_update(changeset),
- {:ok, object} <- Object.set_cache(object) do
+ defp reinject_object(_, new_data) do
+ with {:ok, object, _} <- Pipeline.common_pipeline(new_data, local: false) do
{:ok, object}
else
- e ->
- Logger.error("Error while processing object: #{inspect(e)}")
- {:error, e}
+ e -> e
end
end
diff --git a/lib/pleroma/object/updater.ex b/lib/pleroma/object/updater.ex
index ab38d3ed2..bad811965 100644
--- a/lib/pleroma/object/updater.ex
+++ b/lib/pleroma/object/updater.ex
@@ -5,6 +5,9 @@
defmodule Pleroma.Object.Updater do
require Pleroma.Constants
+ alias Pleroma.Object
+ alias Pleroma.Repo
+
def update_content_fields(orig_object_data, updated_object) do
Pleroma.Constants.status_updatable_fields()
|> Enum.reduce(
@@ -237,4 +240,49 @@ defmodule Pleroma.Object.Updater do
{:history_items, e} -> e
end
end
+
+ defp maybe_touch_changeset(changeset, true) do
+ updated_at =
+ NaiveDateTime.utc_now()
+ |> NaiveDateTime.truncate(:second)
+
+ Ecto.Changeset.put_change(changeset, :updated_at, updated_at)
+ end
+
+ defp maybe_touch_changeset(changeset, _), do: changeset
+
+ def do_update_and_invalidate_cache(orig_object, updated_object, touch_changeset? \\ false) do
+ orig_object_ap_id = updated_object["id"]
+ orig_object_data = orig_object.data
+
+ %{
+ updated_data: updated_object_data,
+ updated: updated,
+ used_history_in_new_object?: used_history_in_new_object?
+ } = make_new_object_data_from_update_object(orig_object_data, updated_object)
+
+ changeset =
+ orig_object
+ |> Repo.preload(:hashtags)
+ |> Object.change(%{data: updated_object_data})
+ |> maybe_touch_changeset(touch_changeset?)
+
+ with {:ok, new_object} <- Repo.update(changeset),
+ {:ok, _} <- Object.invalid_object_cache(new_object),
+ {:ok, _} <- Object.set_cache(new_object),
+ # The metadata/utils.ex uses the object id for the cache.
+ {:ok, _} <- Pleroma.Activity.HTML.invalidate_cache_for(new_object.id) do
+ if used_history_in_new_object? do
+ with create_activity when not is_nil(create_activity) <-
+ Pleroma.Activity.get_create_by_object_ap_id(orig_object_ap_id),
+ {:ok, _} <- Pleroma.Activity.HTML.invalidate_cache_for(create_activity.id) do
+ nil
+ else
+ _ -> nil
+ end
+ end
+
+ {:ok, new_object, updated}
+ end
+ end
end
diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex
index e19642d50..098c177c7 100644
--- a/lib/pleroma/web/activity_pub/side_effects.ex
+++ b/lib/pleroma/web/activity_pub/side_effects.ex
@@ -428,37 +428,13 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
end
if orig_object_data["type"] in Pleroma.Constants.updatable_object_types() do
- %{
- updated_data: updated_object_data,
- updated: updated,
- used_history_in_new_object?: used_history_in_new_object?
- } = Object.Updater.make_new_object_data_from_update_object(orig_object_data, updated_object)
-
- changeset =
- orig_object
- |> Repo.preload(:hashtags)
- |> Object.change(%{data: updated_object_data})
-
- with {:ok, new_object} <- Repo.update(changeset),
- {:ok, _} <- Object.invalid_object_cache(new_object),
- {:ok, _} <- Object.set_cache(new_object),
- # The metadata/utils.ex uses the object id for the cache.
- {:ok, _} <- Pleroma.Activity.HTML.invalidate_cache_for(new_object.id) do
- if used_history_in_new_object? do
- with create_activity when not is_nil(create_activity) <-
- Pleroma.Activity.get_create_by_object_ap_id(orig_object_ap_id),
- {:ok, _} <- Pleroma.Activity.HTML.invalidate_cache_for(create_activity.id) do
- nil
- else
- _ -> nil
- end
- end
+ {:ok, _, updated} =
+ Object.Updater.do_update_and_invalidate_cache(orig_object, updated_object)
- if updated do
- object
- |> Activity.normalize()
- |> ActivityPub.notify_and_stream()
- end
+ if updated do
+ object
+ |> Activity.normalize()
+ |> ActivityPub.notify_and_stream()
end
end
diff --git a/lib/pleroma/web/admin_api/controllers/frontend_controller.ex b/lib/pleroma/web/admin_api/controllers/frontend_controller.ex
index b4dbb82fe..9e2ed4aac 100644
--- a/lib/pleroma/web/admin_api/controllers/frontend_controller.ex
+++ b/lib/pleroma/web/admin_api/controllers/frontend_controller.ex
@@ -18,13 +18,24 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
def index(conn, _params) do
installed = installed()
+ # FIrst get frontends from config,
+ # then add frontends that are installed but not in the config
frontends =
- [:frontends, :available]
- |> Config.get([])
+ Config.get([:frontends, :available], [])
|> Enum.map(fn {name, desc} ->
- Map.put(desc, "installed", name in installed)
+ desc
+ |> Map.put("installed", name in installed)
+ |> Map.put("installed_refs", installed_refs(name))
end)
+ frontends =
+ frontends ++
+ (installed
+ |> Enum.filter(fn n -> not Enum.any?(frontends, fn f -> f["name"] == n end) end)
+ |> Enum.map(fn name ->
+ %{"name" => name, "installed" => true, "installed_refs" => installed_refs(name)}
+ end))
+
render(conn, "index.json", frontends: frontends)
end
@@ -43,4 +54,12 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
[]
end
end
+
+ def installed_refs(name) do
+ if name in installed() do
+ File.ls!(Path.join(Pleroma.Frontend.dir(), name))
+ else
+ []
+ end
+ end
end
diff --git a/lib/pleroma/web/admin_api/views/frontend_view.ex b/lib/pleroma/web/admin_api/views/frontend_view.ex
index 0ca3d67cb..ae4016581 100644
--- a/lib/pleroma/web/admin_api/views/frontend_view.ex
+++ b/lib/pleroma/web/admin_api/views/frontend_view.ex
@@ -15,7 +15,8 @@ defmodule Pleroma.Web.AdminAPI.FrontendView do
git: frontend["git"],
build_url: frontend["build_url"],
ref: frontend["ref"],
- installed: frontend["installed"]
+ installed: frontend["installed"],
+ installed_refs: frontend["installed_refs"]
}
end
end
diff --git a/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex b/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex
index 4bfe5ac5a..3e85c44d2 100644
--- a/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex
@@ -51,8 +51,9 @@ defmodule Pleroma.Web.ApiSpec.Admin.FrontendOperation do
name: %Schema{type: :string},
git: %Schema{type: :string, format: :uri, nullable: true},
build_url: %Schema{type: :string, format: :uri, nullable: true},
- ref: %Schema{type: :string},
- installed: %Schema{type: :boolean}
+ ref: %Schema{type: :string, nullable: true},
+ installed: %Schema{type: :boolean},
+ installed_refs: %Schema{type: :array, items: %Schema{type: :string}}
}
}
}
diff --git a/lib/pleroma/web/plugs/uploaded_media.ex b/lib/pleroma/web/plugs/uploaded_media.ex
index ad8143234..8b3bc9acb 100644
--- a/lib/pleroma/web/plugs/uploaded_media.ex
+++ b/lib/pleroma/web/plugs/uploaded_media.ex
@@ -35,9 +35,9 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
conn =
case fetch_query_params(conn) do
%{query_params: %{"name" => name}} = conn ->
- name = String.replace(name, "\"", "\\\"")
+ name = String.replace(name, ~s["], ~s[\\"])
- put_resp_header(conn, "content-disposition", "filename=\"#{name}\"")
+ put_resp_header(conn, "content-disposition", ~s[inline; filename="#{name}"])
conn ->
conn
diff --git a/priv/scrubbers/default.ex b/priv/scrubbers/default.ex
index e10e3ec87..d1215d2e0 100644
--- a/priv/scrubbers/default.ex
+++ b/priv/scrubbers/default.ex
@@ -33,35 +33,35 @@ defmodule Pleroma.HTML.Scrubber.Default do
"ugc"
])
- Meta.allow_tag_with_these_attributes(:a, ["name", "title"])
-
- Meta.allow_tag_with_these_attributes(:abbr, ["title"])
-
- Meta.allow_tag_with_these_attributes(:b, [])
- Meta.allow_tag_with_these_attributes(:blockquote, [])
- Meta.allow_tag_with_these_attributes(:br, [])
- Meta.allow_tag_with_these_attributes(:code, [])
- Meta.allow_tag_with_these_attributes(:del, [])
- Meta.allow_tag_with_these_attributes(:em, [])
- Meta.allow_tag_with_these_attributes(:hr, [])
- Meta.allow_tag_with_these_attributes(:i, [])
- Meta.allow_tag_with_these_attributes(:li, [])
- Meta.allow_tag_with_these_attributes(:ol, [])
- Meta.allow_tag_with_these_attributes(:p, [])
- Meta.allow_tag_with_these_attributes(:pre, [])
- Meta.allow_tag_with_these_attributes(:strong, [])
- Meta.allow_tag_with_these_attributes(:sub, [])
- Meta.allow_tag_with_these_attributes(:sup, [])
- Meta.allow_tag_with_these_attributes(:ruby, [])
- Meta.allow_tag_with_these_attributes(:rb, [])
- Meta.allow_tag_with_these_attributes(:rp, [])
- Meta.allow_tag_with_these_attributes(:rt, [])
- Meta.allow_tag_with_these_attributes(:rtc, [])
- Meta.allow_tag_with_these_attributes(:u, [])
- Meta.allow_tag_with_these_attributes(:ul, [])
+ Meta.allow_tag_with_these_attributes(:a, ["name", "title", "lang"])
+
+ Meta.allow_tag_with_these_attributes(:abbr, ["title", "lang"])
+
+ Meta.allow_tag_with_these_attributes(:b, ["lang"])
+ Meta.allow_tag_with_these_attributes(:blockquote, ["lang"])
+ Meta.allow_tag_with_these_attributes(:br, ["lang"])
+ Meta.allow_tag_with_these_attributes(:code, ["lang"])
+ Meta.allow_tag_with_these_attributes(:del, ["lang"])
+ Meta.allow_tag_with_these_attributes(:em, ["lang"])
+ Meta.allow_tag_with_these_attributes(:hr, ["lang"])
+ Meta.allow_tag_with_these_attributes(:i, ["lang"])
+ Meta.allow_tag_with_these_attributes(:li, ["lang"])
+ Meta.allow_tag_with_these_attributes(:ol, ["lang"])
+ Meta.allow_tag_with_these_attributes(:p, ["lang"])
+ Meta.allow_tag_with_these_attributes(:pre, ["lang"])
+ Meta.allow_tag_with_these_attributes(:strong, ["lang"])
+ Meta.allow_tag_with_these_attributes(:sub, ["lang"])
+ Meta.allow_tag_with_these_attributes(:sup, ["lang"])
+ Meta.allow_tag_with_these_attributes(:ruby, ["lang"])
+ Meta.allow_tag_with_these_attributes(:rb, ["lang"])
+ Meta.allow_tag_with_these_attributes(:rp, ["lang"])
+ Meta.allow_tag_with_these_attributes(:rt, ["lang"])
+ Meta.allow_tag_with_these_attributes(:rtc, ["lang"])
+ Meta.allow_tag_with_these_attributes(:u, ["lang"])
+ Meta.allow_tag_with_these_attributes(:ul, ["lang"])
Meta.allow_tag_with_this_attribute_values(:span, "class", ["h-card", "recipients-inline"])
- Meta.allow_tag_with_these_attributes(:span, [])
+ Meta.allow_tag_with_these_attributes(:span, ["lang"])
Meta.allow_tag_with_this_attribute_values(:code, "class", ["inline"])
@@ -77,29 +77,30 @@ defmodule Pleroma.HTML.Scrubber.Default do
"width",
"height",
"title",
- "alt"
+ "alt",
+ "lang"
])
end
if Pleroma.Config.get([:markup, :allow_tables]) do
- Meta.allow_tag_with_these_attributes(:table, [])
- Meta.allow_tag_with_these_attributes(:tbody, [])
- Meta.allow_tag_with_these_attributes(:td, [])
- Meta.allow_tag_with_these_attributes(:th, [])
- Meta.allow_tag_with_these_attributes(:thead, [])
- Meta.allow_tag_with_these_attributes(:tr, [])
+ Meta.allow_tag_with_these_attributes(:table, ["lang"])
+ Meta.allow_tag_with_these_attributes(:tbody, ["lang"])
+ Meta.allow_tag_with_these_attributes(:td, ["lang"])
+ Meta.allow_tag_with_these_attributes(:th, ["lang"])
+ Meta.allow_tag_with_these_attributes(:thead, ["lang"])
+ Meta.allow_tag_with_these_attributes(:tr, ["lang"])
end
if Pleroma.Config.get([:markup, :allow_headings]) do
- Meta.allow_tag_with_these_attributes(:h1, [])
- Meta.allow_tag_with_these_attributes(:h2, [])
- Meta.allow_tag_with_these_attributes(:h3, [])
- Meta.allow_tag_with_these_attributes(:h4, [])
- Meta.allow_tag_with_these_attributes(:h5, [])
+ Meta.allow_tag_with_these_attributes(:h1, ["lang"])
+ Meta.allow_tag_with_these_attributes(:h2, ["lang"])
+ Meta.allow_tag_with_these_attributes(:h3, ["lang"])
+ Meta.allow_tag_with_these_attributes(:h4, ["lang"])
+ Meta.allow_tag_with_these_attributes(:h5, ["lang"])
end
if Pleroma.Config.get([:markup, :allow_fonts]) do
- Meta.allow_tag_with_these_attributes(:font, ["face"])
+ Meta.allow_tag_with_these_attributes(:font, ["face", "lang"])
end
Meta.strip_everything_not_covered()
diff --git a/test/pleroma/object/fetcher_test.exs b/test/pleroma/object/fetcher_test.exs
index c8ad66ddb..53c9277d6 100644
--- a/test/pleroma/object/fetcher_test.exs
+++ b/test/pleroma/object/fetcher_test.exs
@@ -9,8 +9,12 @@ defmodule Pleroma.Object.FetcherTest do
alias Pleroma.Instances
alias Pleroma.Object
alias Pleroma.Object.Fetcher
+ alias Pleroma.Web.ActivityPub.ObjectValidator
+
+ require Pleroma.Constants
import Mock
+ import Pleroma.Factory
import Tesla.Mock
setup do
@@ -284,6 +288,8 @@ defmodule Pleroma.Object.FetcherTest do
describe "refetching" do
setup do
+ insert(:user, ap_id: "https://mastodon.social/users/emelie")
+
object1 = %{
"id" => "https://mastodon.social/1",
"actor" => "https://mastodon.social/users/emelie",
@@ -293,10 +299,14 @@ defmodule Pleroma.Object.FetcherTest do
"bcc" => [],
"bto" => [],
"cc" => [],
- "to" => [],
- "summary" => ""
+ "to" => [Pleroma.Constants.as_public()],
+ "summary" => "",
+ "published" => "2023-05-08 23:43:20Z",
+ "updated" => "2023-05-09 23:43:20Z"
}
+ {:ok, local_object1, _} = ObjectValidator.validate(object1, [])
+
object2 = %{
"id" => "https://mastodon.social/2",
"actor" => "https://mastodon.social/users/emelie",
@@ -306,8 +316,10 @@ defmodule Pleroma.Object.FetcherTest do
"bcc" => [],
"bto" => [],
"cc" => [],
- "to" => [],
+ "to" => [Pleroma.Constants.as_public()],
"summary" => "",
+ "published" => "2023-05-08 23:43:20Z",
+ "updated" => "2023-05-09 23:43:25Z",
"formerRepresentations" => %{
"type" => "OrderedCollection",
"orderedItems" => [
@@ -319,14 +331,18 @@ defmodule Pleroma.Object.FetcherTest do
"bcc" => [],
"bto" => [],
"cc" => [],
- "to" => [],
- "summary" => ""
+ "to" => [Pleroma.Constants.as_public()],
+ "summary" => "",
+ "published" => "2023-05-08 23:43:20Z",
+ "updated" => "2023-05-09 23:43:21Z"
}
],
"totalItems" => 1
}
}
+ {:ok, local_object2, _} = ObjectValidator.validate(object2, [])
+
mock(fn
%{
method: :get,
@@ -335,7 +351,7 @@ defmodule Pleroma.Object.FetcherTest do
%Tesla.Env{
status: 200,
headers: [{"content-type", "application/activity+json"}],
- body: Jason.encode!(object1)
+ body: Jason.encode!(object1 |> Map.put("updated", "2023-05-09 23:44:20Z"))
}
%{
@@ -345,7 +361,7 @@ defmodule Pleroma.Object.FetcherTest do
%Tesla.Env{
status: 200,
headers: [{"content-type", "application/activity+json"}],
- body: Jason.encode!(object2)
+ body: Jason.encode!(object2 |> Map.put("updated", "2023-05-09 23:44:20Z"))
}
%{
@@ -370,7 +386,7 @@ defmodule Pleroma.Object.FetcherTest do
apply(HttpRequestMock, :request, [env])
end)
- %{object1: object1, object2: object2}
+ %{object1: local_object1, object2: local_object2}
end
test "it keeps formerRepresentations if remote does not have this attr", %{object1: object1} do
@@ -388,8 +404,9 @@ defmodule Pleroma.Object.FetcherTest do
"bcc" => [],
"bto" => [],
"cc" => [],
- "to" => [],
- "summary" => ""
+ "to" => [Pleroma.Constants.as_public()],
+ "summary" => "",
+ "published" => "2023-05-08 23:43:20Z"
}
],
"totalItems" => 1
@@ -467,6 +484,53 @@ defmodule Pleroma.Object.FetcherTest do
}
} = refetched.data
end
+
+ test "it keeps the history intact if only updated time has changed",
+ %{object1: object1} do
+ full_object1 =
+ object1
+ |> Map.merge(%{
+ "updated" => "2023-05-08 23:43:47Z",
+ "formerRepresentations" => %{
+ "type" => "OrderedCollection",
+ "orderedItems" => [
+ %{"type" => "Note", "content" => "mew mew 1"}
+ ],
+ "totalItems" => 1
+ }
+ })
+
+ {:ok, o} = Object.create(full_object1)
+
+ assert {:ok, refetched} = Fetcher.refetch_object(o)
+
+ assert %{
+ "content" => "test 1",
+ "formerRepresentations" => %{
+ "orderedItems" => [
+ %{"content" => "mew mew 1"}
+ ],
+ "totalItems" => 1
+ }
+ } = refetched.data
+ end
+
+ test "it goes through ObjectValidator and MRF", %{object2: object2} do
+ with_mock Pleroma.Web.ActivityPub.MRF, [:passthrough],
+ filter: fn
+ %{"type" => "Note"} = object ->
+ {:ok, Map.put(object, "content", "MRFd content")}
+
+ arg ->
+ passthrough([arg])
+ end do
+ {:ok, o} = Object.create(object2)
+
+ assert {:ok, refetched} = Fetcher.refetch_object(o)
+
+ assert %{"content" => "MRFd content"} = refetched.data
+ end
+ end
end
describe "fetch with history" do
diff --git a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
index 38a23b224..0d1a4999e 100644
--- a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
@@ -89,6 +89,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
"build_url" => "http://gensokyo.2hu/builds/${ref}",
"git" => nil,
"installed" => true,
+ "installed_refs" => ["fantasy"],
"name" => "pleroma",
"ref" => "fantasy"
}
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs
index 5c9103e9f..968d826a2 100644
--- a/test/pleroma/web/common_api_test.exs
+++ b/test/pleroma/web/common_api_test.exs
@@ -527,6 +527,17 @@ defmodule Pleroma.Web.CommonAPITest do
assert Object.tags(object) == ["ساٴين‌س"]
end
+ test "allows lang attribute" do
+ user = insert(:user)
+ text = ~s{<span lang="en">something</span><p lang="diaetuitech_rpyhpgc">random</p>}
+
+ {:ok, activity} = CommonAPI.post(user, %{status: text, content_type: "text/html"})
+
+ object = Object.normalize(activity, fetch: false)
+
+ assert object.data["content"] == text
+ end
+
test "double dot in link is allowed" do
user = insert(:user)
text = "https://example.to/something..mp3"
diff --git a/test/pleroma/web/plugs/uploaded_media_plug_test.exs b/test/pleroma/web/plugs/uploaded_media_plug_test.exs
index ec46b0537..8323ff6ab 100644
--- a/test/pleroma/web/plugs/uploaded_media_plug_test.exs
+++ b/test/pleroma/web/plugs/uploaded_media_plug_test.exs
@@ -33,11 +33,11 @@ defmodule Pleroma.Web.Plugs.UploadedMediaPlugTest do
test "sends Content-Disposition header when name param is set", %{
attachment_url: attachment_url
} do
- conn = get(build_conn(), attachment_url <> "?name=\"cofe\".gif")
+ conn = get(build_conn(), attachment_url <> ~s[?name="cofe".gif])
assert Enum.any?(
conn.resp_headers,
- &(&1 == {"content-disposition", "filename=\"\\\"cofe\\\".gif\""})
+ &(&1 == {"content-disposition", ~s[inline; filename="\\"cofe\\".gif"]})
)
end
end
diff --git a/tools/check-changelog b/tools/check-changelog
index b94b52755..60692033f 100644
--- a/tools/check-changelog
+++ b/tools/check-changelog
@@ -1,22 +1,18 @@
#!/bin/sh
-echo "looking for change log of $CI_MERGE_REQUEST_IID"
+echo "looking for change log"
-count=0
-for i in add remove fix security skip; do
- [ -f changelog.d/"$CI_MERGE_REQUEST_IID"."$i" ]
- retcode=$?
- if [ $retcode -eq 0 ]; then
- echo "found $CI_MERGE_REQUEST_IID.$i"
- count=$(( count + 1 ))
- else
- echo "no $CI_MERGE_REQUEST_IID.$i"
- fi
-done
-if [ $count -gt 0 ]; then
- echo "ok"
+git remote add upstream https://git.pleroma.social/pleroma/pleroma.git
+git fetch upstream ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}:refs/remotes/upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
+
+git diff --raw --no-renames upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \
+ grep ' A\t' | grep '\.\(skip\|add\|remove\|fix\|security\)$'
+ret=$?
+
+if [ $ret -eq 0 ]; then
+ echo "found a changelog entry"
exit 0
else
- echo "must have a changelog entry or explicitly skip it"
+ echo "changelog entry not found"
exit 1
fi