]> cat aescling's git repositories - mastodon.git/commitdiff
Improve bio compatibility (#2278)
authorEugen <eugen@zeonfederated.com>
Sat, 22 Apr 2017 01:33:24 +0000 (03:33 +0200)
committerGitHub <noreply@github.com>
Sat, 22 Apr 2017 01:33:24 +0000 (03:33 +0200)
* Fix #1057 (close #1819) - Move HTML-formatted bio from <poco:note /> to <summary type="html" />

* Ensure <poco:note /> is plaintext for remote accounts, also, by stripping out HTML

app/lib/atom_serializer.rb
app/services/update_remote_profile_service.rb

index 5aeb7b4f9f3aa9b412288ba02bfa7ecf30a399a0..920eac31b87f8fd32addb0732247b815a5af25e5 100644 (file)
@@ -2,6 +2,7 @@
 
 class AtomSerializer
   include RoutingHelper
+  include ActionView::Helpers::SanitizeHelper
 
   class << self
     def render(element)
@@ -21,13 +22,13 @@ class AtomSerializer
     append_element(author, 'uri', uri)
     append_element(author, 'name', account.username)
     append_element(author, 'email', account.local? ? account.local_username_and_domain : account.acct)
-    append_element(author, 'summary', account.note)
+    append_element(author, 'summary', Formatter.instance.simplified_format(account).to_str, type: :html) if account.note?
     append_element(author, 'link', nil, rel: :alternate, type: 'text/html', href: TagManager.instance.url_for(account))
     append_element(author, 'link', nil, rel: :avatar, type: account.avatar_content_type, 'media:width': 120, 'media:height': 120, href: full_asset_url(account.avatar.url(:original)))
     append_element(author, 'link', nil, rel: :header, type: account.header_content_type, 'media:width': 700, 'media:height': 335, href: full_asset_url(account.header.url(:original)))
     append_element(author, 'poco:preferredUsername', account.username)
     append_element(author, 'poco:displayName', account.display_name) if account.display_name?
-    append_element(author, 'poco:note', Formatter.instance.simplified_format(account).to_str) if account.note?
+    append_element(author, 'poco:note', account.local? ? account.note : strip_tags(account.note)) if account.note?
     append_element(author, 'mastodon:scope', account.locked? ? :private : :public)
 
     author
index 8f0d5d4b30d0f46535627fcf804c161b2a13402b..31f4af2c1222197cc1ca62bfebc0addb4963f015 100644 (file)
@@ -13,8 +13,8 @@ class UpdateRemoteProfileService < BaseService
     hub_link   = xml.at_xpath('./xmlns:link[@rel="hub"]', xmlns: TagManager::XMLNS)
 
     unless author_xml.nil?
-      account.display_name = author_xml.at_xpath('./poco:displayName', poco: TagManager::POCO_XMLNS).content unless author_xml.at_xpath('./poco:displayName', poco: TagManager::POCO_XMLNS).nil?
-      account.note         = author_xml.at_xpath('./poco:note', poco: TagManager::POCO_XMLNS).content unless author_xml.at_xpath('./poco:note', poco: TagManager::POCO_XMLNS).nil?
+      account.display_name = author_xml.at_xpath('./poco:displayName', poco: TagManager::POCO_XMLNS)&.content || ''
+      account.note         = author_xml.at_xpath('./xmlns:summary', xmlns: TagManager::XMLNS)&.content || author_xml.at_xpath('./poco:note', poco: TagManager::POCO_XMLNS)&.content || ''
       account.locked       = author_xml.at_xpath('./mastodon:scope', mastodon: TagManager::MTDN_XMLNS)&.content == 'private'
 
       if !account.suspended? && !DomainBlock.find_by(domain: account.domain)&.reject_media?