]> cat aescling's git repositories - mastodon.git/commitdiff
Merge branch 'main' into glitch-soc/merge-upstream
authorClaire <claire.github-309c@sitedethib.com>
Fri, 19 Mar 2021 12:57:15 +0000 (13:57 +0100)
committerClaire <claire.github-309c@sitedethib.com>
Fri, 19 Mar 2021 12:57:15 +0000 (13:57 +0100)
1  2 
Gemfile
Gemfile.lock
app/lib/formatter.rb
config/environments/production.rb
lib/sanitize_ext/sanitize_config.rb
package.json
spec/lib/sanitize_config_spec.rb
yarn.lock

diff --cc Gemfile
Simple merge
diff --cc Gemfile.lock
index 83202b7d719a0c2583d905b0f8448968fea047b0,106c13554caa62a1fa7ebafd96b7e941c1c52da6..0f32a76b7d5b45ef14d009584367d355edcdf983
@@@ -490,26 -490,9 +490,10 @@@ GE
        link_header (~> 0.0, >= 0.0.8)
      rdf-normalize (0.4.0)
        rdf (~> 3.1)
 +    redcarpet (3.5.1)
      redis (4.2.5)
-     redis-actionpack (5.2.0)
-       actionpack (>= 5, < 7)
-       redis-rack (>= 2.1.0, < 3)
-       redis-store (>= 1.1.0, < 2)
-     redis-activesupport (5.2.0)
-       activesupport (>= 3, < 7)
-       redis-store (>= 1.3, < 2)
      redis-namespace (1.8.1)
        redis (>= 3.0.4)
-     redis-rack (2.1.3)
-       rack (>= 2.0.8, < 3)
-       redis-store (>= 1.2, < 2)
-     redis-rails (5.0.2)
-       redis-actionpack (>= 5.0, < 6)
-       redis-activesupport (>= 5.0, < 6)
-       redis-store (>= 1.2, < 2)
-     redis-store (1.9.0)
-       redis (>= 4, < 5)
      regexp_parser (2.1.1)
      request_store (1.5.0)
        rack (>= 1.4)
@@@ -789,12 -772,10 +773,11 @@@ DEPENDENCIE
    rails-i18n (~> 5.1)
    rails-settings-cached (~> 0.6)
    rdf-normalize (~> 0.4)
 +  redcarpet (~> 3.5)
    redis (~> 4.2)
    redis-namespace (~> 1.8)
-   redis-rails (~> 5.0)
    rqrcode (~> 1.2)
-   rspec-rails (~> 4.1)
+   rspec-rails (~> 5.0)
    rspec-sidekiq (~> 3.1)
    rspec_junit_formatter (~> 0.4)
    rubocop (~> 1.11)
index 9a3e63d46f274a27d98ad0f2f2ff2ec82bc40565,2611bcbae01e95d3ad6e5fe3d271e563cb24efce..02ebe6f896194a98971e6f5cb0f787e06bf05a5b
@@@ -1,31 -1,7 +1,30 @@@
  # frozen_string_literal: true
  
  require 'singleton'
- require_relative './sanitize_config'
  
 +class HTMLRenderer < Redcarpet::Render::HTML
 +  def block_code(code, language)
 +    "<pre><code>#{encode(code).gsub("\n", "<br/>")}</code></pre>"
 +  end
 +
 +  def autolink(link, link_type)
 +    return link if link_type == :email
 +    Formatter.instance.link_url(link)
 +  rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError
 +    encode(link)
 +  end
 +
 +  private
 +
 +  def html_entities
 +    @html_entities ||= HTMLEntities.new
 +  end
 +
 +  def encode(html)
 +    html_entities.encode(html)
 +  end
 +end
 +
  class Formatter
    include Singleton
    include RoutingHelper
Simple merge
Simple merge
diff --cc package.json
Simple merge
index da24f67d61ec0dfe2ee3e17aa031994ec19d86f4,747d81158da4547f8aa3251a282d07c9098c902e..8bcffb2e5ae912b9297108e0022ecebd75e6f4c8
@@@ -1,20 -1,29 +1,19 @@@
  # frozen_string_literal: true
  
  require 'rails_helper'
- require Rails.root.join('app', 'lib', 'sanitize_config.rb')
  
  describe Sanitize::Config do
 -  describe '::MASTODON_STRICT' do
 -    subject { Sanitize::Config::MASTODON_STRICT }
 -
 -    it 'converts h1 to p' do
 -      expect(Sanitize.fragment('<h1>Foo</h1>', subject)).to eq '<p>Foo</p>'
 -    end
 -
 -    it 'converts ul to p' do
 -      expect(Sanitize.fragment('<p>Check out:</p><ul><li>Foo</li><li>Bar</li></ul>', subject)).to eq '<p>Check out:</p><p>Foo<br>Bar</p>'
 -    end
 -
 -    it 'converts p inside ul' do
 -      expect(Sanitize.fragment('<ul><li><p>Foo</p><p>Bar</p></li><li>Baz</li></ul>', subject)).to eq '<p>Foo<br>Bar<br>Baz</p>'
 +  shared_examples 'common HTML sanitization' do
 +    it 'keeps h1' do
 +      expect(Sanitize.fragment('<h1>Foo</h1>', subject)).to eq '<h1>Foo</h1>'
      end
  
 -    it 'converts ul inside ul' do
 -      expect(Sanitize.fragment('<ul><li>Foo</li><li><ul><li>Bar</li><li>Baz</li></ul></li></ul>', subject)).to eq '<p>Foo<br>Bar<br>Baz</p>'
 +    it 'keeps ul' do
 +      expect(Sanitize.fragment('<p>Check out:</p><ul><li>Foo</li><li>Bar</li></ul>', subject)).to eq '<p>Check out:</p><ul><li>Foo</li><li>Bar</li></ul>'
      end
  
 -    it 'keep links in lists' do
 -      expect(Sanitize.fragment('<p>Check out:</p><ul><li><a href="https://joinmastodon.org" rel="nofollow noopener noreferrer" target="_blank">joinmastodon.org</a></li><li>Bar</li></ul>', subject)).to eq '<p>Check out:</p><p><a href="https://joinmastodon.org" rel="nofollow noopener noreferrer" target="_blank">joinmastodon.org</a><br>Bar</p>'
 +    it 'keeps start and reversed attributes of ol' do
 +      expect(Sanitize.fragment('<p>Check out:</p><ol start="3" reversed=""><li>Foo</li><li>Bar</li></ol>', subject)).to eq '<p>Check out:</p><ol start="3" reversed=""><li>Foo</li><li>Bar</li></ol>'
      end
  
      it 'removes a without href' do
diff --cc yarn.lock
Simple merge