logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: 15ec4ae07b17821625bd2ca1088a7573a7ed128c
parent: e43071a2f94354e54816b455e10cc596205af605
Author: Eugen <eugen@zeonfederated.com>
Date:   Mon, 17 Apr 2017 19:58:54 +0200

Fix #1972, fix #1870 - Fix special characters in XML, add tests (#1988)

Also improve efficiency of the mastodon:maintenance:add_static_avatars task

Diffstat:

Mapp/lib/atom_serializer.rb6++----
Mapp/views/api/v1/statuses/_media.rabl4++--
Mlib/tasks/mastodon.rake4++--
3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/app/lib/atom_serializer.rb b/app/lib/atom_serializer.rb @@ -3,13 +3,11 @@ class AtomSerializer include RoutingHelper - INVALID_XML_CHARS = /[^\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]/ - class << self def render(element) document = Ox::Document.new(version: '1.0') document << element - ('<?xml version="1.0"?>' + Ox.dump(element)).force_encoding('UTF-8') + ('<?xml version="1.0"?>' + Ox.dump(element, effort: :tolerant)).force_encoding('UTF-8') end end @@ -319,7 +317,7 @@ class AtomSerializer end def sanitize_str(raw_str) - raw_str.to_s.gsub(INVALID_XML_CHARS, '') + raw_str.to_s end def add_namespaces(parent) diff --git a/app/views/api/v1/statuses/_media.rabl b/app/views/api/v1/statuses/_media.rabl @@ -1,5 +1,5 @@ attributes :id, :remote_url, :type -node(:url) { |media| media.file.blank? ? media.remote_url : full_asset_url(media.file.url(:original)) } -node(:preview_url) { |media| media.file.blank? ? media.remote_url : full_asset_url(media.file.url(:small)) } +node(:url) { |media| full_asset_url(media.file.url(:original)) } +node(:preview_url) { |media| full_asset_url(media.file.url(:small)) } node(:text_url) { |media| media.local? ? medium_url(media) : nil } diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake @@ -145,8 +145,8 @@ namespace :mastodon do Account.unscoped.where(avatar_content_type: 'image/gif').or(Account.unscoped.where(header_content_type: 'image/gif')).find_each do |account| begin - account.avatar.reprocess! - account.header.reprocess! + account.avatar.reprocess! if account.avatar_content_type == 'image/gif' && !account.avatar.exists?(:static) + account.header.reprocess! if account.header_content_type == 'image/gif' && !account.header.exists?(:static) rescue StandardError => e Rails.logger.error "Error while generating static avatars/headers for account #{account.id}: #{e}" next