From 90093f179595fbd73bbdbed3bc2c212dc932e3ec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 16 May 2019 15:00:24 +0900 Subject: Bump aws-sdk-s3 from 1.36.1 to 1.38.0 (#10769) Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.36.1 to 1.38.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/compare/v1.36.1...v1.38.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index 9f11589a6..0e54a5a70 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,18 +75,18 @@ GEM encryptor (~> 3.0.0) av (0.9.0) cocaine (~> 0.5.3) - aws-eventstream (1.0.2) - aws-partitions (1.151.0) - aws-sdk-core (3.48.4) + aws-eventstream (1.0.3) + aws-partitions (1.162.0) + aws-sdk-core (3.52.1) aws-eventstream (~> 1.0, >= 1.0.2) aws-partitions (~> 1.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.17.0) - aws-sdk-core (~> 3, >= 3.48.2) + aws-sdk-kms (1.20.0) + aws-sdk-core (~> 3, >= 3.52.1) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.36.1) - aws-sdk-core (~> 3, >= 3.48.2) + aws-sdk-s3 (1.38.0) + aws-sdk-core (~> 3, >= 3.52.1) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.0) aws-sigv4 (1.1.0) @@ -658,7 +658,7 @@ DEPENDENCIES active_record_query_trace (~> 1.6) addressable (~> 2.6) annotate (~> 2.7) - aws-sdk-s3 (~> 1.36) + aws-sdk-s3 (~> 1.38) better_errors (~> 2.5) binding_of_caller (~> 0.7) blurhash (~> 0.1) -- cgit From 2310dd40fa6a0b3fa9ed6463b75c60ce94f328e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 16 May 2019 16:13:52 +0900 Subject: Bump capybara from 3.19.1 to 3.20.0 (#10768) Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.19.1 to 3.20.0. - [Release notes](https://github.com/teamcapybara/capybara/releases) - [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md) - [Commits](https://github.com/teamcapybara/capybara/compare/3.19.1...3.20.0) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 0d1b02fce..c9840016d 100644 --- a/Gemfile +++ b/Gemfile @@ -108,7 +108,7 @@ group :production, :test do end group :test do - gem 'capybara', '~> 3.19' + gem 'capybara', '~> 3.20' gem 'climate_control', '~> 0.2' gem 'faker', '~> 1.9' gem 'microformats', '~> 4.1' diff --git a/Gemfile.lock b/Gemfile.lock index 0e54a5a70..2bcf17562 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,13 +129,14 @@ GEM sshkit (~> 1.3) capistrano-yarn (2.0.2) capistrano (~> 3.0) - capybara (3.19.1) + capybara (3.20.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (~> 1.2) + uglifier xpath (~> 3.2) case_transform (0.2) activesupport @@ -207,6 +208,7 @@ GEM et-orbi (1.1.6) tzinfo excon (0.62.0) + execjs (2.7.0) fabrication (2.20.2) faker (1.9.3) i18n (>= 0.7) @@ -497,7 +499,7 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.5.0) redis (>= 2.2, < 5) - regexp_parser (1.4.0) + regexp_parser (1.5.0) request_store (1.4.1) rack (>= 1.4) responders (2.4.1) @@ -625,6 +627,8 @@ GEM thread_safe (~> 0.1) tzinfo-data (1.2019.1) tzinfo (>= 1.0.0) + uglifier (4.1.20) + execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.5) @@ -671,7 +675,7 @@ DEPENDENCIES capistrano-rails (~> 1.4) capistrano-rbenv (~> 2.1) capistrano-yarn (~> 2.0) - capybara (~> 3.19) + capybara (~> 3.20) charlock_holmes (~> 0.7.6) chewy (~> 5.0) cld3 (~> 3.2.4) -- cgit From e976a9dfbd33a5ac373dc1dd633df203b4b08ffe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 17 May 2019 15:23:21 +0900 Subject: Bump aws-sdk-s3 from 1.38.0 to 1.39.0 (#10773) Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.38.0 to 1.39.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/compare/v1.38.0...v1.39.0) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index c9840016d..ec7f36c47 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'makara', '~> 0.4' gem 'pghero', '~> 2.2' gem 'dotenv-rails', '~> 2.7' -gem 'aws-sdk-s3', '~> 1.38', require: false +gem 'aws-sdk-s3', '~> 1.39', require: false gem 'fog-core', '<= 2.1.0' gem 'fog-openstack', '~> 0.3', require: false gem 'paperclip', '~> 6.0' diff --git a/Gemfile.lock b/Gemfile.lock index 2bcf17562..2dde7ac64 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,7 +85,7 @@ GEM aws-sdk-kms (1.20.0) aws-sdk-core (~> 3, >= 3.52.1) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.38.0) + aws-sdk-s3 (1.39.0) aws-sdk-core (~> 3, >= 3.52.1) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.0) @@ -662,7 +662,7 @@ DEPENDENCIES active_record_query_trace (~> 1.6) addressable (~> 2.6) annotate (~> 2.7) - aws-sdk-s3 (~> 1.38) + aws-sdk-s3 (~> 1.39) better_errors (~> 2.5) binding_of_caller (~> 0.7) blurhash (~> 0.1) -- cgit From 94aef563b9abbc449028f44c4aac84ef2e072d89 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 12 May 2019 20:20:05 +0200 Subject: Add support for markdown-formatted toots --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/lib/formatter.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 6 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index b9a9159de..31cf743a4 100644 --- a/Gemfile +++ b/Gemfile @@ -95,6 +95,8 @@ gem 'json-ld', '~> 3.0' gem 'json-ld-preloaded', '~> 3.0' gem 'rdf-normalize', '~> 0.3' +gem 'redcarpet', '~> 3.4' + group :development, :test do gem 'fabrication', '~> 2.20' gem 'fuubar', '~> 2.3' diff --git a/Gemfile.lock b/Gemfile.lock index 98cd2103d..8e3f1faf7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -480,6 +480,7 @@ GEM link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.3.3) rdf (>= 2.2, < 4.0) + redcarpet (3.4.0) redis (4.1.1) redis-actionpack (5.0.2) actionpack (>= 4.0, < 6) @@ -745,6 +746,7 @@ DEPENDENCIES rails-i18n (~> 5.1) rails-settings-cached (~> 0.6) rdf-normalize (~> 0.3) + redcarpet (~> 3.4) redis (~> 4.1) redis-namespace (~> 1.5) redis-rails (~> 5.0) diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 8a1aad41a..fe5b5b7b7 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -36,14 +36,52 @@ class Formatter html = raw_content html = "RT @#{prepend_reblog} #{html}" if prepend_reblog - html = encode_and_link_urls(html, linkable_accounts) + html = format_markdown(html) if status.content_type == 'text/markdown' + html = encode_and_link_urls(html, linkable_accounts, keep_html: status.content_type == 'text/markdown') html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify] - html = simple_format(html, {}, sanitize: false) + html = simple_format(html, {}, sanitize: false) unless status.content_type == 'text/markdown' html = html.delete("\n") html.html_safe # rubocop:disable Rails/OutputSafety end + def format_markdown(html) + extensions = { + autolink: false, + no_intra_emphasis: true, + fenced_code_blocks: true, + disable_indented_code_blocks: true, + strikethrough: true, + lax_spacing: true, + space_after_headers: true, + superscript: true, + underline: true, + highlight: true, + footnotes: true + } + + renderer = Redcarpet::Render::HTML.new({ + filter_html: false, + no_images: true, + no_styles: true, + safe_links_only: true, + hard_wrap: true, + link_attributes: { target: '_blank', rel: 'nofollow noopener' }, + }) + + markdown = Redcarpet::Markdown.new(renderer, extensions) + + html = reformat(markdown.render(html)) + html = html.gsub("\r\n", "\n").gsub("\r", "\n") + code_safe_strip(html) + end + + def code_safe_strip(html, char="\n") + html = html.split(/(].*?\/code>)/m) + html.each_slice(2) { |part| part[0].delete!(char) } + html.join + end + def reformat(html) sanitize(html, Sanitize::Config::MASTODON_STRICT) end @@ -116,7 +154,7 @@ class Formatter accounts = nil end - rewrite(html.dup, entities) do |entity| + rewrite(html.dup, entities, options[:keep_html]) do |entity| if entity[:url] link_to_url(entity, options) elsif entity[:hashtag] @@ -186,7 +224,7 @@ class Formatter html end - def rewrite(text, entities) + def rewrite(text, entities, keep_html = false) text = text.to_s # Sort by start index @@ -199,12 +237,12 @@ class Formatter last_index = entities.reduce(0) do |index, entity| indices = entity.respond_to?(:indices) ? entity.indices : entity[:indices] - result << encode(text[index...indices.first]) + result << (keep_html ? text[index...indices.first] : encode(text[index...indices.first])) result << yield(entity) indices.last end - result << encode(text[last_index..-1]) + result << (keep_html ? text[last_index..-1] : encode(text[last_index..-1])) result.flatten.join end -- cgit