diff options
Diffstat (limited to 'app')
23 files changed, 33 insertions, 36 deletions
diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js index 6f57c1950..f230823cc 100644 --- a/app/javascript/flavours/glitch/components/poll.js +++ b/app/javascript/flavours/glitch/components/poll.js @@ -153,7 +153,7 @@ class Poll extends ImmutablePureComponent { </span>} <span - className='poll__option__text' + className='poll__option__text translate' dangerouslySetInnerHTML={{ __html: titleEmojified }} /> diff --git a/app/javascript/flavours/glitch/features/compose/components/reply_indicator.js b/app/javascript/flavours/glitch/features/compose/components/reply_indicator.js index 0fd07c282..37ae9cab9 100644 --- a/app/javascript/flavours/glitch/features/compose/components/reply_indicator.js +++ b/app/javascript/flavours/glitch/features/compose/components/reply_indicator.js @@ -66,7 +66,7 @@ class ReplyIndicator extends ImmutablePureComponent { )} </header> <div - className='content' + className='content translate' dangerouslySetInnerHTML={{ __html: content || '' }} /> {attachments.size > 0 && ( diff --git a/app/javascript/flavours/glitch/features/directory/components/account_card.js b/app/javascript/flavours/glitch/features/directory/components/account_card.js index 2ef9d5ba4..5f952b382 100644 --- a/app/javascript/flavours/glitch/features/directory/components/account_card.js +++ b/app/javascript/flavours/glitch/features/directory/components/account_card.js @@ -241,7 +241,7 @@ class AccountCard extends ImmutablePureComponent { <div className='directory__card__extra' ref={this.setRef}> <div - className='account__header__content' + className='account__header__content translate' dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }} /> </div> diff --git a/app/javascript/flavours/glitch/features/follow_requests/components/account_authorize.js b/app/javascript/flavours/glitch/features/follow_requests/components/account_authorize.js index bf145cb67..eb9f3db7e 100644 --- a/app/javascript/flavours/glitch/features/follow_requests/components/account_authorize.js +++ b/app/javascript/flavours/glitch/features/follow_requests/components/account_authorize.js @@ -35,7 +35,7 @@ class AccountAuthorize extends ImmutablePureComponent { <DisplayName account={account} /> </Permalink> - <div className='account__header__content' dangerouslySetInnerHTML={content} /> + <div className='account__header__content translate' dangerouslySetInnerHTML={content} /> </div> <div className='account--panel'> diff --git a/app/javascript/mastodon/components/poll.js b/app/javascript/mastodon/components/poll.js index 41c99710f..477f56e13 100644 --- a/app/javascript/mastodon/components/poll.js +++ b/app/javascript/mastodon/components/poll.js @@ -153,7 +153,7 @@ class Poll extends ImmutablePureComponent { </span>} <span - className='poll__option__text' + className='poll__option__text translate' dangerouslySetInnerHTML={{ __html: titleEmojified }} /> diff --git a/app/javascript/mastodon/features/account/components/header.js b/app/javascript/mastodon/features/account/components/header.js index 0b4431d62..4647b98b2 100644 --- a/app/javascript/mastodon/features/account/components/header.js +++ b/app/javascript/mastodon/features/account/components/header.js @@ -340,7 +340,7 @@ class Header extends ImmutablePureComponent { {account.get('id') !== me && !suspended && <AccountNoteContainer account={account} />} - {account.get('note').length > 0 && account.get('note') !== '<p></p>' && <div className='account__header__content' dangerouslySetInnerHTML={content} className='translate' />} + {account.get('note').length > 0 && account.get('note') !== '<p></p>' && <div className='account__header__content translate' dangerouslySetInnerHTML={content} />} </div> {!suspended && ( diff --git a/app/javascript/mastodon/features/compose/components/reply_indicator.js b/app/javascript/mastodon/features/compose/components/reply_indicator.js index 856383893..a1d5c420c 100644 --- a/app/javascript/mastodon/features/compose/components/reply_indicator.js +++ b/app/javascript/mastodon/features/compose/components/reply_indicator.js @@ -56,7 +56,7 @@ class ReplyIndicator extends ImmutablePureComponent { </a> </div> - <div className='reply-indicator__content' dangerouslySetInnerHTML={content} /> + <div className='reply-indicator__content translate' dangerouslySetInnerHTML={content} /> {status.get('media_attachments').size > 0 && ( <AttachmentList diff --git a/app/javascript/mastodon/features/directory/components/account_card.js b/app/javascript/mastodon/features/directory/components/account_card.js index 419ab9e11..e37733828 100644 --- a/app/javascript/mastodon/features/directory/components/account_card.js +++ b/app/javascript/mastodon/features/directory/components/account_card.js @@ -241,7 +241,7 @@ class AccountCard extends ImmutablePureComponent { <div className='directory__card__extra' ref={this.setRef}> <div - className='account__header__content' + className='account__header__content translate' dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }} /> </div> diff --git a/app/javascript/mastodon/features/follow_requests/components/account_authorize.js b/app/javascript/mastodon/features/follow_requests/components/account_authorize.js index a3b524db1..8269f5ae4 100644 --- a/app/javascript/mastodon/features/follow_requests/components/account_authorize.js +++ b/app/javascript/mastodon/features/follow_requests/components/account_authorize.js @@ -35,7 +35,7 @@ class AccountAuthorize extends ImmutablePureComponent { <DisplayName account={account} /> </Permalink> - <div className='account__header__content' dangerouslySetInnerHTML={content} /> + <div className='account__header__content translate' dangerouslySetInnerHTML={content} /> </div> <div className='account--panel'> diff --git a/app/lib/extractor.rb b/app/lib/extractor.rb index 479689d60..6076458ad 100644 --- a/app/lib/extractor.rb +++ b/app/lib/extractor.rb @@ -7,14 +7,14 @@ module Extractor # :yields: username, list_slug, start, end def extract_mentions_or_lists_with_indices(text) - return [] unless text =~ Twitter::Regex[:at_signs] + return [] unless Twitter::Regex[:at_signs].match?(text) possible_entries = [] text.to_s.scan(Account::MENTION_RE) do |screen_name, _| match_data = $LAST_MATCH_INFO after = $' - unless after =~ Twitter::Regex[:end_mention_match] + unless Twitter::Regex[:end_mention_match].match?(after) start_position = match_data.char_begin(1) - 1 end_position = match_data.char_end(1) possible_entries << { @@ -33,7 +33,7 @@ module Extractor end def extract_hashtags_with_indices(text, **) - return [] unless text =~ /#/ + return [] unless /#/.match?(text) tags = [] text.scan(Tag::HASHTAG_RE) do |hash_text, _| @@ -41,7 +41,7 @@ module Extractor start_position = match_data.char_begin(1) - 1 end_position = match_data.char_end(1) after = $' - if after =~ %r{\A://} + if %r{\A://}.match?(after) hash_text.match(/(.+)(https?\Z)/) do |matched| hash_text = matched[1] end_position -= matched[2].char_length diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index ddd975c5f..2e70c2ce9 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -454,8 +454,8 @@ class FeedManager active_filters.map! do |filter| if filter.whole_word - sb = filter.phrase =~ /\A[[:word:]]/ ? '\b' : '' - eb = filter.phrase =~ /[[:word:]]\z/ ? '\b' : '' + sb = /\A[[:word:]]/.match?(filter.phrase) ? '\b' : '' + eb = /[[:word:]]\z/.match?(filter.phrase) ? '\b' : '' /(?mix:#{sb}#{Regexp.escape(filter.phrase)}#{eb})/ else @@ -475,7 +475,7 @@ class FeedManager status.media_attachments.map(&:description).join("\n\n"), ].compact.join("\n\n") - !combined_regex.match(combined_text).nil? + combined_regex.match?(combined_text) end # Adds a status to an account's feed, returning true if a status was diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index e7bb0743d..1aeedac8a 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -287,7 +287,7 @@ class Formatter escaped = text.chars.map do |c| output = begin - if c.ord.to_s(16).length > 2 && UNICODE_ESCAPE_BLACKLIST_RE.match(c).nil? + if c.ord.to_s(16).length > 2 && !UNICODE_ESCAPE_BLACKLIST_RE.match?(c) CGI.escape(c) else c diff --git a/app/lib/request.rb b/app/lib/request.rb index 38048dad7..125dee3ea 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -145,7 +145,7 @@ class Request end def block_hidden_service? - !Rails.configuration.x.access_to_hidden_service && /\.(onion|i2p)$/.match(@url.host) + !Rails.configuration.x.access_to_hidden_service && /\.(onion|i2p)$/.match?(@url.host) end module ClientLimit diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb index 0fb415bd1..ecaec2f84 100644 --- a/app/lib/sanitize_config.rb +++ b/app/lib/sanitize_config.rb @@ -28,9 +28,9 @@ class Sanitize return unless class_list class_list.keep_if do |e| - next true if e =~ /^(h|p|u|dt|e)-/ # microformats classes - next true if e =~ /^(mention|hashtag)$/ # semantic classes - next true if e =~ /^(ellipsis|invisible)$/ # link formatting classes + next true if /^(h|p|u|dt|e)-/.match?(e) # microformats classes + next true if /^(mention|hashtag)$/.match?(e) # semantic classes + next true if /^(ellipsis|invisible)$/.match?(e) # link formatting classes end node['class'] = class_list.join(' ') diff --git a/app/lib/spam_check.rb b/app/lib/spam_check.rb index 68e586d00..dcb2db9ca 100644 --- a/app/lib/spam_check.rb +++ b/app/lib/spam_check.rb @@ -186,9 +186,9 @@ class SpamCheck def matching_status_ids if nilsimsa? - other_digests.select { |record| record.start_with?('nilsimsa') && nilsimsa_compare_value(digest, record.split(':')[1]) >= NILSIMSA_COMPARE_THRESHOLD }.filter_map { |record| record.split(':')[2] } + other_digests.filter_map { |record| record.split(':')[2] if record.start_with?('nilsimsa') && nilsimsa_compare_value(digest, record.split(':')[1]) >= NILSIMSA_COMPARE_THRESHOLD } else - other_digests.select { |record| record.start_with?('md5') && record.split(':')[1] == digest }.filter_map { |record| record.split(':')[2] } + other_digests.filter_map { |record| record.split(':')[2] if record.start_with?('md5') && record.split(':')[1] == digest } end end diff --git a/app/models/concerns/omniauthable.rb b/app/models/concerns/omniauthable.rb index 4ea219537..79d671d10 100644 --- a/app/models/concerns/omniauthable.rb +++ b/app/models/concerns/omniauthable.rb @@ -57,7 +57,7 @@ module Omniauthable user = User.new(user_params_from_auth(email, auth)) - user.account.avatar_remote_url = auth.info.image if auth.info.image =~ /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/ + user.account.avatar_remote_url = auth.info.image if /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/.match?(auth.info.image) user.skip_confirmation! user.save! user diff --git a/app/presenters/status_relationships_presenter.rb b/app/presenters/status_relationships_presenter.rb index f4849d245..70fb2ba90 100644 --- a/app/presenters/status_relationships_presenter.rb +++ b/app/presenters/status_relationships_presenter.rb @@ -15,7 +15,7 @@ class StatusRelationshipsPresenter statuses = statuses.compact status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id] }.uniq.compact conversation_ids = statuses.filter_map(&:conversation_id).uniq - pinnable_status_ids = statuses.map(&:proper).select { |s| s.account_id == current_account_id && %w(public unlisted).include?(s.visibility) }.map(&:id) + pinnable_status_ids = statuses.map(&:proper).filter_map { |s| s.id if s.account_id == current_account_id && %w(public unlisted).include?(s.visibility) } @reblogs_map = Status.reblogs_map(status_ids, current_account_id).merge(options[:reblogs_map] || {}) @favourites_map = Status.favourites_map(status_ids, current_account_id).merge(options[:favourites_map] || {}) diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb index 43e596040..6fe4b6593 100644 --- a/app/services/account_search_service.rb +++ b/app/services/account_search_service.rb @@ -175,7 +175,7 @@ class AccountSearchService < BaseService end def username_complete? - query.include?('@') && "@#{query}" =~ /\A#{Account::MENTION_RE}\Z/ + query.include?('@') && "@#{query}".match?(/\A#{Account::MENTION_RE}\Z/) end def likely_acct? diff --git a/app/services/activitypub/fetch_featured_collection_service.rb b/app/services/activitypub/fetch_featured_collection_service.rb index 82c861f5b..72352aca6 100644 --- a/app/services/activitypub/fetch_featured_collection_service.rb +++ b/app/services/activitypub/fetch_featured_collection_service.rb @@ -23,11 +23,8 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService def process_items(items) status_ids = items.map { |item| value_or_id(item) } - .reject { |uri| ActivityPub::TagManager.instance.local_uri?(uri) } - .filter_map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri) } - .select { |status| status.account_id == @account.id } - .map(&:id) - + .filter_map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri) unless ActivityPub::TagManager.instance.local_uri?(uri) } + .filter_map { |status| status.id if status.account_id == @account.id } to_remove = [] to_add = status_ids diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 255490d5c..74fe9a0a5 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -47,11 +47,11 @@ class FetchLinkCardService < BaseService Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => Mastodon::Version.user_agent + ' Bot').perform do |res| if res.code == 200 && res.mime_type == 'text/html' - @html = res.body_with_limit @html_charset = res.charset + @html = res.body_with_limit else - @html = nil @html_charset = nil + @html = nil end end end diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 19500a8d4..1a76cbb38 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -72,7 +72,7 @@ class SearchService < BaseService end def url_query? - @resolve && @query =~ /\Ahttps?:\/\// + @resolve && /\Ahttps?:\/\//.match?(@query) end def url_resource_results diff --git a/app/validators/blacklisted_email_validator.rb b/app/validators/blacklisted_email_validator.rb index 16e3abf12..20a1587cc 100644 --- a/app/validators/blacklisted_email_validator.rb +++ b/app/validators/blacklisted_email_validator.rb @@ -22,7 +22,7 @@ class BlacklistedEmailValidator < ActiveModel::Validator domains = Rails.configuration.x.email_domains_blacklist.gsub('.', '\.') regexp = Regexp.new("@(.+\\.)?(#{domains})", true) - @email =~ regexp + regexp.match?(@email) end def not_on_whitelist? diff --git a/app/validators/html_validator.rb b/app/validators/html_validator.rb index 1c9cd303c..b85b9769f 100644 --- a/app/validators/html_validator.rb +++ b/app/validators/html_validator.rb @@ -15,6 +15,6 @@ class HtmlValidator < ActiveModel::EachValidator def html_errors(str) fragment = Nokogiri::HTML.fragment(options[:wrap_with] ? "<#{options[:wrap_with]}>#{str}</#{options[:wrap_with]}>" : str) - fragment.errors.select { |error| ERROR_RE =~ error.message } + fragment.errors.select { |error| ERROR_RE.match?(error.message) } end end |