/source.json: strip html tags from artist commentary.

This commit is contained in:
evazion
2017-05-01 21:24:02 -05:00
parent b2f62482a1
commit 8015d62b46
2 changed files with 18 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ module Sources
:profile_url, :image_url, :tags, :artist_record, :unique_id,
:page_count, :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls,
:artist_commentary_title, :artist_commentary_desc,
:dtext_artist_commentary_title, :dtext_artist_commentary_desc,
:rewrite_thumbnails, :illust_id_from_url, :to => :strategy
def self.strategies
@@ -70,6 +71,8 @@ module Sources
:artist_commentary => {
:title => artist_commentary_title,
:description => artist_commentary_desc,
:dtext_title => dtext_artist_commentary_title,
:dtext_description => dtext_artist_commentary_desc,
}
}
end

View File

@@ -86,10 +86,25 @@ module Sources
nil
end
def dtext_artist_commentary_title
self.class.to_dtext(artist_commentary_title)
end
def dtext_artist_commentary_desc
self.class.to_dtext(artist_commentary_desc)
end
protected
def agent
raise NotImplementedError
end
# Convert commentary to dtext by stripping html tags. Sites can override
# this to customize how their markup is translated to dtext.
def self.to_dtext(text)
text = Rails::Html::FullSanitizer.new.sanitize(text, encode_special_chars: false)
text
end
end
end
end