From 481e1d4e0e59ddda8da781a16fcffe25aa4f3cda Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 20 Sep 2023 15:59:53 +0200 Subject: [PATCH 1/2] Fix post translation erroring out (v4.0.x) (#26991) --- app/lib/translation_service/deepl.rb | 2 +- app/lib/translation_service/libre_translate.rb | 2 +- app/services/translate_status_service.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/translation_service/deepl.rb b/app/lib/translation_service/deepl.rb index 537fd24c0..2b4746a4d 100644 --- a/app/lib/translation_service/deepl.rb +++ b/app/lib/translation_service/deepl.rb @@ -46,7 +46,7 @@ class TranslationService::DeepL < TranslationService raise UnexpectedResponseError unless json.is_a?(Hash) - Translation.new(text: json.dig('translations', 0, 'text'), detected_source_language: json.dig('translations', 0, 'detected_source_language')&.downcase, provider: 'DeepL.com') + Translation.new(text: Sanitize.fragment(json.dig('translations', 0, 'text'), Sanitize::Config::MASTODON_STRICT), detected_source_language: json.dig('translations', 0, 'detected_source_language')&.downcase, provider: 'DeepL.com') rescue Oj::ParseError raise UnexpectedResponseError end diff --git a/app/lib/translation_service/libre_translate.rb b/app/lib/translation_service/libre_translate.rb index 43576e306..ee668d298 100644 --- a/app/lib/translation_service/libre_translate.rb +++ b/app/lib/translation_service/libre_translate.rb @@ -37,7 +37,7 @@ class TranslationService::LibreTranslate < TranslationService raise UnexpectedResponseError unless json.is_a?(Hash) - Translation.new(text: json['translatedText'], detected_source_language: source_language, provider: 'LibreTranslate') + Translation.new(text: Sanitize.fragment(json['translatedText'], Sanitize::Config::MASTODON_STRICT), detected_source_language: source_language, provider: 'LibreTranslate') rescue Oj::ParseError raise UnexpectedResponseError end diff --git a/app/services/translate_status_service.rb b/app/services/translate_status_service.rb index b905f8158..6e6ed87b0 100644 --- a/app/services/translate_status_service.rb +++ b/app/services/translate_status_service.rb @@ -12,8 +12,8 @@ class TranslateStatusService < BaseService @content = status_content_format(@status) @target_language = target_language - Rails.cache.fetch("translations/#{@status.language}/#{@target_language}/#{content_hash}", expires_in: CACHE_TTL) do - Sanitize.fragment(translation_backend.translate(@content, @status.language, @target_language), Sanitize::Config::MASTODON_STRICT) + Rails.cache.fetch("translations:v2/#{@status.language}/#{@target_language}/#{content_hash}", expires_in: CACHE_TTL) do + translation_backend.translate(@content, @status.language, @target_language) end end From 89f98f4b636f017ef12f9bd0eccf9ff1f5905149 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 20 Sep 2023 17:25:00 +0200 Subject: [PATCH 2/2] Bump version to v4.0.11 (#26996) --- CHANGELOG.md | 6 ++++++ docker-compose.yml | 6 +++--- lib/mastodon/version.rb | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d251f9879..35ad9caea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file. **The 4.0.x branch will not receive any update after 2023-10-31.** This means that no security fix will be made available for this branch after this date, and you will need to update to a more recent version (such as the 4.1.x branch) to receive security fixes. +## [4.0.11] - 2023-09-20 + +### Fixed + +- Fix post translation erroring out ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/26990)) + ## [4.0.10] - 2023-09-19 ### Fixed diff --git a/docker-compose.yml b/docker-compose.yml index c59d0b525..dbe314a12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,7 +56,7 @@ services: web: build: . - image: ghcr.io/mastodon/mastodon:v4.0.10 + image: ghcr.io/mastodon/mastodon:v4.0.11 restart: always env_file: .env.production command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" @@ -77,7 +77,7 @@ services: streaming: build: . - image: ghcr.io/mastodon/mastodon:v4.0.10 + image: ghcr.io/mastodon/mastodon:v4.0.11 restart: always env_file: .env.production command: node ./streaming @@ -95,7 +95,7 @@ services: sidekiq: build: . - image: ghcr.io/mastodon/mastodon:v4.0.10 + image: ghcr.io/mastodon/mastodon:v4.0.11 restart: always env_file: .env.production command: bundle exec sidekiq diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 30abeb433..f4fb2dd88 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -13,7 +13,7 @@ module Mastodon end def patch - 10 + 11 end def flags