Rebase to current 4.3.0-alpha-glitch-soc, update theming files
This commit is contained in:
1 parent
aeb49bcba0
commit
fff7926498
71 files changed
+30937
-2221
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
enabled = ENV['ES_ENABLED'] == 'true'
|
||||
host = ENV.fetch('ES_HOST') { 'localhost' }
|
||||
port = ENV.fetch('ES_PORT') { 9200 }
|
||||
user = ENV.fetch('ES_USER', nil).presence
|
||||
password = ENV.fetch('ES_PASS', nil).presence
|
||||
fallback_prefix = ENV.fetch('REDIS_NAMESPACE', nil).presence
|
||||
prefix = ENV.fetch('ES_PREFIX') { fallback_prefix }
|
||||
|
||||
Chewy.settings = {
|
||||
host: "#{host}:#{port}",
|
||||
prefix: prefix,
|
||||
enabled: enabled,
|
||||
journal: false,
|
||||
user: user,
|
||||
password: password,
|
||||
index: {
|
||||
number_of_replicas: ['single_node_cluster', nil].include?(ENV['ES_PRESET'].presence) ? 0 : 1,
|
||||
},
|
||||
}
|
||||
|
||||
# We use our own async strategy even outside the request-response
|
||||
# cycle, which takes care of checking if Elasticsearch is enabled
|
||||
# or not. However, mind that for the Rails console, the :urgent
|
||||
# strategy is set automatically with no way to override it.
|
||||
<<<<<<< HEAD
|
||||
Chewy.root_strategy = :bypass_with_warning if Rails.env.production?
|
||||
=======
|
||||
>>>>>>> 479b66637 (Fix sidekiq jobs not triggering Elasticsearch index updates (#24046))
|
||||
Chewy.request_strategy = :mastodon
|
||||
Chewy.use_after_commit_callbacks = false
|
||||
|
||||
# Elasticsearch uses Faraday internally. Faraday interprets the
|
||||
# http_proxy env variable by default which leads to issues when
|
||||
# Mastodon is run with hidden services enabled, because
|
||||
# Elasticsearch is *not* supposed to be accessed through a proxy
|
||||
Faraday.ignore_env_proxy = true
|
||||
@@ -0,0 +1,120 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Define an application-wide content security policy.
|
||||
# See the Securing Rails Applications Guide for more information:
|
||||
# https://guides.rubyonrails.org/security.html#content-security-policy-header
|
||||
|
||||
def host_to_url(str)
|
||||
<<<<<<< HEAD
|
||||
return if str.blank?
|
||||
|
||||
uri = Addressable::URI.parse("http#{Rails.configuration.x.use_https ? 's' : ''}://#{str}")
|
||||
uri.path += '/' unless uri.path.blank? || uri.path.end_with?('/')
|
||||
uri.to_s
|
||||
=======
|
||||
"http#{Rails.configuration.x.use_https ? 's' : ''}://#{str}".split('/').first if str.present?
|
||||
>>>>>>> a197fc094 (Fix CSP headers when S3_ALIAS_HOST includes a path component (#25273))
|
||||
end
|
||||
|
||||
def sso_host
|
||||
return unless ENV['ONE_CLICK_SSO_LOGIN'] == 'true'
|
||||
return unless ENV['OMNIAUTH_ONLY'] == 'true'
|
||||
return unless Devise.omniauth_providers.length == 1
|
||||
|
||||
provider = Devise.omniauth_configs[Devise.omniauth_providers[0]]
|
||||
@sso_host ||= begin
|
||||
case provider.provider
|
||||
when :cas
|
||||
provider.cas_url
|
||||
when :saml
|
||||
provider.options[:idp_sso_target_url]
|
||||
when :openid_connect
|
||||
provider.options.dig(:client_options, :authorization_endpoint) || OpenIDConnect::Discovery::Provider::Config.discover!(provider.options[:issuer]).authorization_endpoint
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Rails.env.development?
|
||||
assets_host = Rails.configuration.action_controller.asset_host || "https://#{ENV['WEB_DOMAIN'] || ENV['LOCAL_DOMAIN']}"
|
||||
data_hosts = [assets_host]
|
||||
|
||||
if ENV['S3_ENABLED'] == 'true' || ENV['AZURE_ENABLED'] == 'true'
|
||||
attachments_host = host_to_url(ENV['S3_ALIAS_HOST'] || ENV['S3_CLOUDFRONT_HOST'] || ENV['AZURE_ALIAS_HOST'] || ENV['S3_HOSTNAME'] || "s3-#{ENV['S3_REGION'] || 'us-east-1'}.amazonaws.com")
|
||||
elsif ENV['SWIFT_ENABLED'] == 'true'
|
||||
attachments_host = ENV['SWIFT_OBJECT_URL']
|
||||
attachments_host = "https://#{Addressable::URI.parse(attachments_host).host}"
|
||||
else
|
||||
attachments_host = nil
|
||||
end
|
||||
|
||||
data_hosts << attachments_host unless attachments_host.nil?
|
||||
|
||||
if ENV['PAPERCLIP_ROOT_URL']
|
||||
url = Addressable::URI.parse(assets_host) + ENV['PAPERCLIP_ROOT_URL']
|
||||
data_hosts << "https://#{url.host}"
|
||||
end
|
||||
|
||||
data_hosts.concat(ENV['EXTRA_DATA_HOSTS'].split('|')) if ENV['EXTRA_DATA_HOSTS']
|
||||
|
||||
data_hosts.uniq!
|
||||
|
||||
Rails.application.config.content_security_policy do |p|
|
||||
p.base_uri :none
|
||||
p.default_src :none
|
||||
p.frame_ancestors :none
|
||||
p.script_src :self, assets_host, "'wasm-unsafe-eval'"
|
||||
p.font_src :self, assets_host
|
||||
p.img_src :self, :data, :blob, *data_hosts
|
||||
p.style_src :self, assets_host
|
||||
p.media_src :self, :data, *data_hosts
|
||||
p.frame_src :self, :https
|
||||
p.child_src :self, :blob, assets_host
|
||||
p.worker_src :self, :blob, assets_host
|
||||
p.connect_src :self, :blob, :data, Rails.configuration.x.streaming_api_base_url, *data_hosts
|
||||
p.manifest_src :self, assets_host
|
||||
|
||||
if sso_host.present?
|
||||
p.form_action :self, sso_host
|
||||
else
|
||||
p.form_action :self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Report CSP violations to a specified URI
|
||||
# For further information see the following documentation:
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
||||
# Rails.application.config.content_security_policy_report_only = true
|
||||
|
||||
Rails.application.config.content_security_policy_nonce_generator = ->request { SecureRandom.base64(16) }
|
||||
|
||||
Rails.application.config.content_security_policy_nonce_directives = %w(style-src)
|
||||
|
||||
Rails.application.reloader.to_prepare do
|
||||
PgHero::HomeController.content_security_policy do |p|
|
||||
p.script_src :self, :unsafe_inline, assets_host
|
||||
p.style_src :self, :unsafe_inline, assets_host
|
||||
end
|
||||
|
||||
PgHero::HomeController.after_action do
|
||||
request.content_security_policy_nonce_generator = nil
|
||||
end
|
||||
|
||||
if Rails.env.development?
|
||||
LetterOpenerWeb::LettersController.content_security_policy do |p|
|
||||
p.child_src :self
|
||||
p.connect_src :none
|
||||
p.frame_ancestors :self
|
||||
p.frame_src :self
|
||||
p.script_src :unsafe_inline
|
||||
p.style_src :unsafe_inline
|
||||
p.worker_src :none
|
||||
end
|
||||
|
||||
LetterOpenerWeb::LettersController.after_action do |p|
|
||||
request.content_security_policy_nonce_directives = %w(script-src)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,88 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Twitter::TwitterText
|
||||
class Configuration
|
||||
def emoji_parsing_enabled
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
class Regex
|
||||
REGEXEN[:valid_general_url_path_chars] = /[^\p{White_Space}<>()?]/iou
|
||||
REGEXEN[:valid_url_path_ending_chars] = /[^\p{White_Space}()?!*"'「」<>;:=,.$%\[\]~&|@]|(?:#{REGEXEN[:valid_url_balanced_parens]})/iou
|
||||
REGEXEN[:valid_url_balanced_parens] = /
|
||||
\(
|
||||
(?:
|
||||
#{REGEXEN[:valid_general_url_path_chars]}+
|
||||
|
|
||||
# allow one nested level of balanced parentheses
|
||||
(?:
|
||||
#{REGEXEN[:valid_general_url_path_chars]}*
|
||||
\(
|
||||
#{REGEXEN[:valid_general_url_path_chars]}+
|
||||
\)
|
||||
#{REGEXEN[:valid_general_url_path_chars]}*
|
||||
)
|
||||
)
|
||||
\)
|
||||
/iox
|
||||
# rubocop:disable Layout/LineLength
|
||||
UCHARS = '\u{A0}-\u{D7FF}\u{F900}-\u{FDCF}\u{FDF0}-\u{FFEF}\u{10000}-\u{1FFFD}\u{20000}-\u{2FFFD}\u{30000}-\u{3FFFD}\u{40000}-\u{4FFFD}\u{50000}-\u{5FFFD}\u{60000}-\u{6FFFD}\u{70000}-\u{7FFFD}\u{80000}-\u{8FFFD}\u{90000}-\u{9FFFD}\u{A0000}-\u{AFFFD}\u{B0000}-\u{BFFFD}\u{C0000}-\u{CFFFD}\u{D0000}-\u{DFFFD}\u{E1000}-\u{EFFFD}\u{E000}-\u{F8FF}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}'
|
||||
<<<<<<< HEAD
|
||||
# rubocop:enable Layout/LineLength
|
||||
REGEXEN[:valid_url_query_chars] = %r{[a-z0-9!?*'();:&=+$/%#\[\]\-_.,~|@\^#{UCHARS}]}iou
|
||||
REGEXEN[:valid_url_query_ending_chars] = %r{[a-z0-9_&=#/\-#{UCHARS}]}iou
|
||||
REGEXEN[:valid_url_path] = %r{(?:
|
||||
=======
|
||||
REGEXEN[:valid_url_query_chars] = /[a-z0-9!?\*'\(\);:&=\+\$\/%#\[\]\-_\.,~|@\^#{UCHARS}]/iou
|
||||
REGEXEN[:valid_url_query_ending_chars] = /[a-z0-9_&=#\/\-#{UCHARS}]/iou
|
||||
REGEXEN[:valid_url_path] = /(?:
|
||||
>>>>>>> 8eb1bb8ba (Allow carets in URL search params (#25216))
|
||||
(?:
|
||||
#{REGEXEN[:valid_general_url_path_chars]}*
|
||||
(?:#{REGEXEN[:valid_url_balanced_parens]} #{REGEXEN[:valid_general_url_path_chars]}*)*
|
||||
#{REGEXEN[:valid_url_path_ending_chars]}
|
||||
)|(?:#{REGEXEN[:valid_general_url_path_chars]}+/)
|
||||
)}iox
|
||||
REGEXEN[:valid_url] = %r{
|
||||
( # $1 total match
|
||||
(#{REGEXEN[:valid_url_preceding_chars]}) # $2 Preceding character
|
||||
( # $3 URL
|
||||
((?:https?|dat|dweb|ipfs|ipns|ssb|gopher|gemini)://)? # $4 Protocol (optional)
|
||||
(#{REGEXEN[:valid_domain]}) # $5 Domain(s)
|
||||
(?::(#{REGEXEN[:valid_port_number]}))? # $6 Port number (optional)
|
||||
(/#{REGEXEN[:valid_url_path]}*)? # $7 URL Path and anchor
|
||||
(\?#{REGEXEN[:valid_url_query_chars]}*#{REGEXEN[:valid_url_query_ending_chars]})? # $8 Query String
|
||||
)
|
||||
)
|
||||
}iox
|
||||
REGEXEN[:validate_nodeid] = /(?:
|
||||
#{REGEXEN[:validate_url_unreserved]}|
|
||||
#{REGEXEN[:validate_url_pct_encoded]}|
|
||||
[!$()*+,;=]
|
||||
)/iox
|
||||
REGEXEN[:validate_resid] = /(?:
|
||||
#{REGEXEN[:validate_url_unreserved]}|
|
||||
#{REGEXEN[:validate_url_pct_encoded]}|
|
||||
#{REGEXEN[:validate_url_sub_delims]}
|
||||
)/iox
|
||||
REGEXEN[:valid_extended_uri] = %r{
|
||||
( # $1 total match
|
||||
(#{REGEXEN[:valid_url_preceding_chars]}) # $2 Preceding character
|
||||
( # $3 URL
|
||||
(
|
||||
(xmpp:) # Protocol
|
||||
(//#{REGEXEN[:validate_nodeid]}+@#{REGEXEN[:valid_domain]}/)? # Authority (optional)
|
||||
(#{REGEXEN[:validate_nodeid]}+@)? # Username in path (optional)
|
||||
(#{REGEXEN[:valid_domain]}) # Domain in path
|
||||
(/#{REGEXEN[:validate_resid]}+)? # Resource in path (optional)
|
||||
(\?#{REGEXEN[:valid_url_query_chars]}*#{REGEXEN[:valid_url_query_ending_chars]})? # Query String
|
||||
) | (
|
||||
(magnet:) # Protocol
|
||||
(\?#{REGEXEN[:valid_url_query_chars]}*#{REGEXEN[:valid_url_query_ending_chars]}) # Query String
|
||||
)
|
||||
)
|
||||
)
|
||||
}iox
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user