From: Thibaut Girka Date: Sun, 12 Jan 2020 14:57:34 +0000 (+0100) Subject: Merge branch 'master' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=980c004f0601bbfaf440c0ea56de408ccfd79007;p=mastodon.git Merge branch 'master' into glitch-soc/merge-upstream Conflicts: - `Gemfile.lock`: No real conflict, glitch-soc-only dependency (redcarpet) too close to an upstream one (rdf-normalize) - `README.md`: we have different READMEs, discarded upstream's changes - `app/views/admin/custom_emojis/index.html.haml`: No real conflict, different context because of glitch-soc theming - `lib/mastodon/statuses_cli.rb`: Upstream added code to keep bookmarked statuses, we were already doing so with slightly different code. Discarded upstream's changes. - `package.json`: No real conflict, glitch-soc-only dependency (favico.js) too close to an upstream one --- 980c004f0601bbfaf440c0ea56de408ccfd79007 diff --cc Gemfile index 7e409ffa1,316ebb81d..c365da554 --- a/Gemfile +++ b/Gemfile @@@ -52,9 -55,8 +55,9 @@@ gem 'goldfinger', '~> 2.1 gem 'hiredis', '~> 0.6' gem 'redis-namespace', '~> 1.7' gem 'health_check', git: 'https://github.com/ianheggie/health_check', ref: '0b799ead604f900ed50685e9b2d469cd2befba5b' +gem 'html2text' gem 'htmlentities', '~> 4.3' - gem 'http', '~> 3.3' + gem 'http', '~> 4.3' gem 'http_accept_language', '~> 2.1' gem 'http_parser.rb', '~> 0.6', git: 'https://github.com/tmm1/http_parser.rb', ref: '54b17ba8c7d8d20a16dfc65d1775241833219cf2', submodules: true gem 'httplog', '~> 1.3' @@@ -100,10 -101,8 +102,10 @@@ gem 'webpush gem 'json-ld', git: 'https://github.com/ruby-rdf/json-ld.git', ref: 'e742697a0906e74e8bb777ef98137bc3955d981d' gem 'json-ld-preloaded', '~> 3.0' - gem 'rdf-normalize', '~> 0.3' + gem 'rdf-normalize', '~> 0.4' +gem 'redcarpet', '~> 3.4' + group :development, :test do gem 'fabrication', '~> 2.21' gem 'fuubar', '~> 2.5' diff --cc Gemfile.lock index a2def3c6e,44682002a..ec7ac0f5a --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -292,17 -296,17 +296,19 @@@ GE highline (2.0.1) hiredis (0.6.3) hkdf (0.3.0) + html2text (0.2.1) + nokogiri (~> 1.6) htmlentities (4.3.4) - http (3.3.0) + http (4.3.0) addressable (~> 2.3) http-cookie (~> 1.0) - http-form_data (~> 2.0) - http_parser.rb (~> 0.6.0) + http-form_data (~> 2.2) + http-parser (~> 1.2.0) http-cookie (1.0.3) domain_name (~> 0.5) - http-form_data (2.1.1) + http-form_data (2.2.0) + http-parser (1.2.1) + ffi-compiler (>= 1.0, < 2.0) http_accept_language (2.1.1) httplog (1.3.3) rack (>= 1.0) @@@ -506,12 -506,11 +508,12 @@@ thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (13.0.1) - rdf (3.0.13) + rdf (3.1.0) hamster (~> 3.0) link_header (~> 0.0, >= 0.0.8) - rdf-normalize (0.3.3) - rdf (>= 2.2, < 4.0) + rdf-normalize (0.4.0) + rdf (~> 3.1) + redcarpet (3.4.0) redis (4.1.3) redis-actionpack (5.0.2) actionpack (>= 4.0, < 6) @@@ -723,9 -726,8 +729,9 @@@ DEPENDENCIE hamlit-rails (~> 0.2) health_check! hiredis (~> 0.6) + html2text htmlentities (~> 4.3) - http (~> 3.3) + http (~> 4.3) http_accept_language (~> 2.1) http_parser.rb (~> 0.6)! httplog (~> 1.3) @@@ -775,8 -776,7 +780,8 @@@ rails-controller-testing (~> 1.0) rails-i18n (~> 5.1) rails-settings-cached (~> 0.6) - rdf-normalize (~> 0.3) + rdf-normalize (~> 0.4) + redcarpet (~> 3.4) redis (~> 4.1) redis-namespace (~> 1.7) redis-rails (~> 5.0) diff --cc app/lib/formatter.rb index 9159db2a1,c771dcaaa..36cdae9f7 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@@ -308,33 -245,11 +308,34 @@@ class Formatte end standard = Extractor.extract_entities_with_indices(text, options) + xmpp = Extractor.extract_xmpp_uris_with_indices(text, options) - Extractor.remove_overlapping_entities(special + standard) + Extractor.remove_overlapping_entities(special + standard + xmpp) end + def html_friendly_extractor(html, options = {}) + gaps = [] + total_offset = 0 + + escaped = html.gsub(/<[^>]*>|&#[0-9]+;/) do |match| + total_offset += match.length - 1 + end_offset = Regexp.last_match.end(0) + gaps << [end_offset - total_offset, total_offset] + "\u200b" + end + + entities = Extractor.extract_hashtags_with_indices(escaped, :check_url_overlap => false) + + Extractor.extract_mentions_or_lists_with_indices(escaped) + Extractor.remove_overlapping_entities(entities).map do |extract| + pos = extract[:indices].first + offset_idx = gaps.rindex { |gap| gap.first <= pos } + offset = offset_idx.nil? ? 0 : gaps[offset_idx].last + next extract.merge( + :indices => [extract[:indices].first + offset, extract[:indices].last + offset] + ) + end + end + def link_to_url(entity, options = {}) url = Addressable::URI.parse(entity[:url]) html_attrs = { target: '_blank', rel: 'nofollow noopener noreferrer' } diff --cc app/views/admin/custom_emojis/index.html.haml index 4fbadee90,389e9dd71..dc9ebf507 --- a/app/views/admin/custom_emojis/index.html.haml +++ b/app/views/admin/custom_emojis/index.html.haml @@@ -1,6 -1,12 +1,9 @@@ - content_for :page_title do = t('admin.custom_emojis.title') -- content_for :header_tags do - = javascript_pack_tag 'admin', integrity: true, async: true, crossorigin: 'anonymous' - + - content_for :heading_actions do + = link_to t('admin.custom_emojis.upload'), new_admin_custom_emoji_path, class: 'button' + .filters .filter-subset %strong= t('admin.accounts.location.title') diff --cc package.json index d72c9b93d,2726fd1c0..649ecbbcb --- a/package.json +++ b/package.json @@@ -95,8 -93,7 +95,8 @@@ "escape-html": "^1.0.3", "exif-js": "^2.3.0", "express": "^4.17.1", - "file-loader": "^4.2.0", + "file-loader": "^5.0.2", + "favico.js": "^0.3.10", "font-awesome": "^4.7.0", "glob": "^7.1.6", "history": "^4.10.1",