decidim-core 0.31.7 → 0.31.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/address_cell.rb +7 -3
- data/app/cells/decidim/card_metadata_cell.rb +3 -1
- data/app/cells/decidim/content_blocks/participatory_space_main_data/title.erb +1 -14
- data/app/cells/decidim/date_range/show.erb +6 -6
- data/app/cells/decidim/date_range_cell.rb +7 -2
- data/app/cells/decidim/following_cell.rb +1 -1
- data/app/cells/decidim/nav_links/show.erb +3 -1
- data/app/cells/decidim/participatory_space_private_user/show.erb +1 -1
- data/app/cells/decidim/share_text_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/qr_code_modal.erb +2 -4
- data/app/commands/decidim/create_follow.rb +3 -7
- data/app/commands/decidim/create_omniauth_registration.rb +19 -7
- data/app/commands/decidim/create_user_report.rb +1 -1
- data/app/commands/decidim/destroy_account.rb +6 -6
- data/app/commands/decidim/destroy_ephemeral_user.rb +2 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +17 -3
- data/app/commands/decidim/update_resources_taxonomies.rb +2 -1
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +4 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +4 -0
- data/app/controllers/concerns/decidim/direct_upload.rb +12 -6
- data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +2 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +2 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +4 -4
- data/app/controllers/concerns/decidim/locale_switcher.rb +62 -11
- data/app/controllers/concerns/decidim/needs_organization.rb +15 -0
- data/app/controllers/concerns/decidim/needs_permission.rb +22 -10
- data/app/controllers/concerns/decidim/onboarding_action_methods.rb +2 -0
- data/app/controllers/concerns/decidim/paginable.rb +7 -3
- data/app/controllers/concerns/decidim/payload_info.rb +2 -0
- data/app/controllers/concerns/decidim/resource_versions_concern.rb +14 -0
- data/app/controllers/decidim/amendments_controller.rb +34 -6
- data/app/controllers/decidim/application_controller.rb +2 -6
- data/app/controllers/decidim/authorization_modals_controller.rb +3 -1
- data/app/controllers/decidim/components/base_controller.rb +2 -0
- data/app/controllers/decidim/devise/passwords_controller.rb +8 -0
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +10 -4
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +6 -1
- data/app/controllers/decidim/favicon_controller.rb +9 -0
- data/app/controllers/decidim/free_resource_authorization_modals_controller.rb +2 -0
- data/app/controllers/decidim/gamification/badges_controller.rb +2 -0
- data/app/controllers/decidim/homepage_controller.rb +4 -1
- data/app/controllers/decidim/likes_controller.rb +1 -1
- data/app/controllers/decidim/links_controller.rb +2 -0
- data/app/controllers/decidim/manifests_controller.rb +2 -0
- data/app/controllers/decidim/messaging/conversations_controller.rb +11 -5
- data/app/controllers/decidim/newsletters_controller.rb +4 -0
- data/app/controllers/decidim/notifications_subscriptions_controller.rb +4 -0
- data/app/controllers/decidim/offline_controller.rb +5 -1
- data/app/controllers/decidim/open_data_controller.rb +5 -1
- data/app/controllers/decidim/pages_controller.rb +31 -3
- data/app/controllers/decidim/private_downloads_controller.rb +2 -0
- data/app/controllers/decidim/profiles_controller.rb +11 -1
- data/app/controllers/decidim/qr_controller.rb +3 -1
- data/app/controllers/decidim/resource_autocomplete_controller.rb +2 -0
- data/app/controllers/decidim/searches_controller.rb +2 -0
- data/app/controllers/decidim/short_links_controller.rb +4 -0
- data/app/controllers/decidim/static_map_controller.rb +2 -0
- data/app/controllers/decidim/timeouts_controller.rb +4 -0
- data/app/controllers/decidim/tos_controller.rb +2 -0
- data/app/controllers/decidim/upload_validations_controller.rb +4 -2
- data/app/controllers/decidim/user_activities_controller.rb +2 -0
- data/app/forms/decidim/upload_validation_form.rb +16 -10
- data/app/helpers/concerns/decidim/user_role_checker.rb +35 -10
- data/app/helpers/decidim/cells_paginate_helper.rb +0 -5
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/orders_helper.rb +8 -6
- data/app/helpers/decidim/paginate_helper.rb +27 -2
- data/app/helpers/decidim/sanitize_helper.rb +11 -1
- data/app/helpers/decidim/url_helper.rb +35 -0
- data/app/jobs/decidim/application_job.rb +4 -0
- data/app/jobs/decidim/open_data_job.rb +21 -5
- data/app/models/decidim/action_log.rb +7 -1
- data/app/models/decidim/authorization.rb +24 -0
- data/app/models/decidim/component.rb +10 -0
- data/app/models/decidim/like.rb +1 -1
- data/app/models/decidim/oauth_application.rb +1 -0
- data/app/models/decidim/user.rb +1 -0
- data/app/models/decidim/user_base_entity.rb +1 -1
- data/app/packs/src/decidim/callout.js +10 -0
- data/app/packs/src/decidim/callout.test.js +32 -0
- data/app/packs/src/decidim/controllers/accordion/accordion.test.js +64 -0
- data/app/packs/src/decidim/controllers/accordion/controller.js +43 -0
- data/app/packs/src/decidim/datepicker/datepicker_functions.js +54 -30
- data/app/packs/src/decidim/datepicker/form_datepicker.js +18 -2
- data/app/packs/src/decidim/datepicker/generate_datepicker.js +16 -8
- data/app/packs/src/decidim/datepicker/generate_timepicker.js +5 -3
- data/app/packs/src/decidim/datepicker/test/date.test.js +8 -0
- data/app/packs/src/decidim/datepicker/test/time.test.js +39 -24
- data/app/packs/src/decidim/utilities/dom.js +2 -2
- data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -10
- data/app/packs/stylesheets/decidim/_conversations.scss +0 -8
- data/app/packs/stylesheets/decidim/_datepicker.scss +3 -3
- data/app/packs/stylesheets/decidim/_modal.scss +16 -8
- data/app/packs/stylesheets/decidim/_modal_share.scss +0 -22
- data/app/packs/stylesheets/decidim/_participatory_spaces.scss +11 -1
- data/app/packs/stylesheets/decidim/_rich_text.scss +12 -9
- data/app/packs/stylesheets/decidim/_spinner.scss +16 -0
- data/app/packs/stylesheets/decidim/_tom_select.scss +1 -1
- data/app/packs/stylesheets/decidim/_typography.scss +5 -2
- data/app/packs/stylesheets/decidim/legacy/email.scss +0 -5
- data/app/permissions/decidim/permissions.rb +20 -0
- data/app/presenters/decidim/admin_log/component_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +20 -2
- data/app/presenters/decidim/log/user_presenter.rb +2 -2
- data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +11 -2
- data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +25 -1
- data/app/services/decidim/action_logger.rb +97 -29
- data/app/services/decidim/svg_content_validator.rb +889 -0
- data/app/uploaders/decidim/application_uploader.rb +2 -2
- data/app/validators/uploader_image_content_validator.rb +282 -0
- data/app/views/decidim/application/_radio_accordion.html.erb +1 -5
- data/app/views/decidim/manifests/show.json.erb +25 -22
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -3
- data/app/views/decidim/shared/_login_modal.html.erb +12 -14
- data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
- data/app/views/layouts/decidim/_mailer_logo.html.erb +1 -1
- data/config/initializers/rack_attack.rb +10 -0
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca-IT.yml +8 -4
- data/config/locales/ca.yml +10 -6
- data/config/locales/cs.yml +16 -4
- data/config/locales/de.yml +62 -6
- data/config/locales/en.yml +8 -4
- data/config/locales/es-MX.yml +8 -4
- data/config/locales/es-PY.yml +8 -4
- data/config/locales/es.yml +14 -10
- data/config/locales/eu.yml +165 -164
- data/config/locales/fi-plain.yml +3 -3
- data/config/locales/fi.yml +3 -3
- data/config/locales/fr-CA.yml +8 -4
- data/config/locales/fr.yml +8 -4
- data/config/locales/gl.yml +1440 -33
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -2
- data/config/locales/ja.yml +4 -4
- data/config/locales/pl.yml +1 -4
- data/config/locales/pt-BR.yml +1 -4
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/sk.yml +51 -4
- data/config/locales/sv.yml +50 -13
- data/config/locales/tr-TR.yml +1 -3
- data/db/migrate/20250523104311_move_cta_to_hero_content_block.rb +1 -1
- data/db/migrate/20250527122040_move_highlighted_content_banner_settings_to_content_block.rb +3 -0
- data/db/migrate/20260909000000_add_failed_attempts_and_locked_at_to_decidim_authorizations.rb +8 -0
- data/db/migrate/20261007090000_make_user_optional_in_action_logs.rb +12 -0
- data/decidim-core.gemspec +1 -1
- data/lib/decidim/content_renderers/mention_resource_renderer.rb +6 -3
- data/lib/decidim/core/test/factories.rb +2 -2
- data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +77 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_members_shared_examples.rb +85 -6
- data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +23 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +10 -1
- data/lib/decidim/has_upload_validations.rb +1 -0
- data/lib/decidim/legacy_form_builder.rb +4 -0
- data/lib/decidim/maintenance/import_models/scope.rb +2 -1
- data/lib/decidim/maintenance/taxonomy_importer.rb +4 -1
- data/lib/decidim/query_extensions.rb +2 -0
- data/lib/decidim/view_model.rb +1 -0
- data/lib/tasks/decidim_open_data_tasks.rake +7 -0
- metadata +22 -10
|
@@ -40,7 +40,7 @@ module Decidim
|
|
|
40
40
|
|
|
41
41
|
def url(options = {})
|
|
42
42
|
representable = model.send(mounted_as)
|
|
43
|
-
return
|
|
43
|
+
return unless representable.is_a? ActiveStorage::Attached
|
|
44
44
|
|
|
45
45
|
variant_url(options.delete(:variant), **options)
|
|
46
46
|
end
|
|
@@ -54,7 +54,7 @@ module Decidim
|
|
|
54
54
|
|
|
55
55
|
def path(options = {})
|
|
56
56
|
representable = model.send(mounted_as)
|
|
57
|
-
return
|
|
57
|
+
return unless representable.is_a? ActiveStorage::Attached
|
|
58
58
|
|
|
59
59
|
variant_path(options.delete(:variant), **options)
|
|
60
60
|
end
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This validator ensures that files declared as images actually contain valid
|
|
4
|
+
# image data of the declared format. It does so by checking the leading bytes
|
|
5
|
+
# (magic bytes / file signature) of the file against the known signatures of
|
|
6
|
+
# the supported image formats, and by comparing the detected format with the
|
|
7
|
+
# content type declared by the file.
|
|
8
|
+
#
|
|
9
|
+
# This prevents non-image files (e.g. HTML, MATLAB, or arbitrary binary data)
|
|
10
|
+
# from being uploaded with an image extension and a spoofed image content type.
|
|
11
|
+
# Such files would later cause image processing to fail (e.g. in ImageMagick or
|
|
12
|
+
# in libvips when generating a variant) and could lead to a denial of service.
|
|
13
|
+
#
|
|
14
|
+
# Comparing the detected format with the declared content type also prevents
|
|
15
|
+
# files whose contents do not match their declaration (e.g. a JPEG file
|
|
16
|
+
# declared as image/png), so that the stored MIME type is consistent with the
|
|
17
|
+
# file contents.
|
|
18
|
+
#
|
|
19
|
+
# SVG documents are XML-based and can contain scripts and other active content,
|
|
20
|
+
# which is executed when the document is rendered by the browser. Because of
|
|
21
|
+
# that, the contents of files detected as SVG are additionally validated by
|
|
22
|
+
# Decidim::SvgContentValidator, so that documents which could execute scripts
|
|
23
|
+
# or read external resources are rejected instead of being stored as they are.
|
|
24
|
+
class UploaderImageContentValidator < ActiveModel::Validations::FileContentTypeValidator
|
|
25
|
+
# The number of leading bytes to read from the file to detect its signature.
|
|
26
|
+
SIGNATURE_LENGTH = 128
|
|
27
|
+
|
|
28
|
+
# The known signatures of the supported binary image formats. Each entry
|
|
29
|
+
# associates a format with a list of [offset, bytes] pairs that must all
|
|
30
|
+
# match at their respective offsets for the file to be considered of that
|
|
31
|
+
# format.
|
|
32
|
+
BINARY_IMAGE_SIGNATURES = [
|
|
33
|
+
[:png, [[0, "\x89PNG\r\n\x1A\n".b]]],
|
|
34
|
+
[:jpeg, [[0, "\xFF\xD8\xFF".b]]],
|
|
35
|
+
[:gif, [[0, "GIF87a".b]]],
|
|
36
|
+
[:gif, [[0, "GIF89a".b]]],
|
|
37
|
+
[:bmp, [[0, "BM".b]]],
|
|
38
|
+
[:tiff, [[0, "II*\x00".b]]],
|
|
39
|
+
[:tiff, [[0, "MM\x00*".b]]],
|
|
40
|
+
[:webp, [[0, "RIFF".b], [8, "WEBP".b]]],
|
|
41
|
+
[:ico, [[0, "\x00\x00\x01\x00".b]]]
|
|
42
|
+
].freeze
|
|
43
|
+
|
|
44
|
+
# The major brands of the ISOBMFF "ftyp" box that identify HEIF and AVIF
|
|
45
|
+
# images. These formats share the same leading layout as other "ftyp" files
|
|
46
|
+
# (e.g. MP4 video), so the brand at offset 8 is used to tell images apart.
|
|
47
|
+
# The brands are grouped per format family, because HEIF files may use any
|
|
48
|
+
# of the HEIF brands regardless of their extension (e.g. a ".heic" file
|
|
49
|
+
# with the "mif1" major brand).
|
|
50
|
+
FTYPE_IMAGE_BRANDS = {
|
|
51
|
+
heif: %w(heic heix hevc hevx mif1 msf1).map(&:b).freeze,
|
|
52
|
+
avif: %w(avif avis).map(&:b).freeze
|
|
53
|
+
}.freeze
|
|
54
|
+
|
|
55
|
+
# The leading markup of an SVG document, which is XML-based and therefore has
|
|
56
|
+
# no fixed binary signature. The XML declaration is optional, and the document
|
|
57
|
+
# type declaration, comments and processing instructions are legal before the
|
|
58
|
+
# root element, so a document can start with any of them. Files detected as SVG
|
|
59
|
+
# are then checked by Decidim::SvgContentValidator, which requires an "svg"
|
|
60
|
+
# root element, so an XML document which is not an SVG is still rejected.
|
|
61
|
+
SVG_SIGNATURES = ["<svg".b, "<?".b, "<!--".b, "<!DOCTYPE".b].freeze
|
|
62
|
+
|
|
63
|
+
# The content types accepted for each image format detected from the file
|
|
64
|
+
# signature. The content type declared by the file must be one of these, so
|
|
65
|
+
# that the stored MIME type is consistent with the file contents. The lists
|
|
66
|
+
# include the aliases commonly used in the wild for the same format.
|
|
67
|
+
FORMAT_CONTENT_TYPES = {
|
|
68
|
+
png: %w(image/png),
|
|
69
|
+
jpeg: %w(image/jpeg image/jpg image/pjpeg),
|
|
70
|
+
gif: %w(image/gif),
|
|
71
|
+
bmp: %w(image/bmp image/x-ms-bmp image/windows-bmp),
|
|
72
|
+
tiff: %w(image/tiff image/x-tiff),
|
|
73
|
+
webp: %w(image/webp),
|
|
74
|
+
ico: %w(image/vnd.microsoft.icon image/x-icon image/ico image/icon),
|
|
75
|
+
heif: %w(image/heic image/heif image/heic-sequence image/heif-sequence),
|
|
76
|
+
avif: %w(image/avif image/avis),
|
|
77
|
+
svg: %w(image/svg+xml)
|
|
78
|
+
}.freeze
|
|
79
|
+
|
|
80
|
+
def validate_each(record, attribute, value)
|
|
81
|
+
begin
|
|
82
|
+
values = parse_values(value)
|
|
83
|
+
rescue JSON::ParserError
|
|
84
|
+
record.errors.add attribute, :invalid
|
|
85
|
+
return
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
return if values.empty?
|
|
89
|
+
|
|
90
|
+
values.each do |val|
|
|
91
|
+
validate_image_content(record, attribute, val)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def check_validity!; end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def validate_image_content(record, attribute, file)
|
|
100
|
+
content_type = normalize_content_type(declared_content_type(file))
|
|
101
|
+
return unless content_type.start_with?("image/")
|
|
102
|
+
|
|
103
|
+
signature = file_signature(file)
|
|
104
|
+
return if signature.nil?
|
|
105
|
+
|
|
106
|
+
detected = image_format(signature)
|
|
107
|
+
return add_invalid_image(record, attribute) unless valid_image_format?(detected, content_type)
|
|
108
|
+
|
|
109
|
+
validate_svg_content(record, attribute, file) if detected == :svg
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# The content type declared by the file, either through the blob of an
|
|
113
|
+
# attached file or through the upload itself.
|
|
114
|
+
def declared_content_type(file)
|
|
115
|
+
if file.is_a?(ActiveStorage::Attached)
|
|
116
|
+
file.blob&.content_type
|
|
117
|
+
else
|
|
118
|
+
file.try(:content_type)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Strips the content type parameters (e.g. "image/png;charset=binary") and
|
|
123
|
+
# normalizes the casing, as content types are case insensitive.
|
|
124
|
+
def normalize_content_type(content_type)
|
|
125
|
+
content_type.to_s.split(";", 2).first.to_s.strip.downcase
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Whether the format detected from the file signature is one of the
|
|
129
|
+
# supported image formats and is consistent with the content type declared
|
|
130
|
+
# by the file.
|
|
131
|
+
def valid_image_format?(detected, content_type)
|
|
132
|
+
return false if detected.nil?
|
|
133
|
+
|
|
134
|
+
FORMAT_CONTENT_TYPES.fetch(detected).include?(content_type)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Validates the contents of a file detected as SVG, which can contain active
|
|
138
|
+
# content. The validation is delegated to Decidim::SvgContentValidator, so
|
|
139
|
+
# that the SVG specific logic is kept out of this validator. Documents which
|
|
140
|
+
# are not well formed SVG documents are rejected as invalid images, and the
|
|
141
|
+
# ones which could execute scripts or read external resources when they are
|
|
142
|
+
# rendered are rejected as unsafe files.
|
|
143
|
+
def validate_svg_content(record, attribute, file)
|
|
144
|
+
case Decidim::SvgContentValidator.validate(file_content(file))
|
|
145
|
+
when :invalid
|
|
146
|
+
add_invalid_image(record, attribute)
|
|
147
|
+
when :unsafe
|
|
148
|
+
add_unsafe_svg(record, attribute)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def add_invalid_image(record, attribute)
|
|
153
|
+
record.errors.add attribute, I18n.t("decidim.errors.files.file_is_not_a_valid_image")
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def add_unsafe_svg(record, attribute)
|
|
157
|
+
record.errors.add attribute, I18n.t("decidim.errors.files.file_contains_unsafe_content")
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Reads the leading bytes (signature) of the file. Returns nil when the file
|
|
161
|
+
# cannot be read, in which case the validation is skipped. Empty files yield
|
|
162
|
+
# an empty signature, which is rejected.
|
|
163
|
+
def file_signature(file)
|
|
164
|
+
read_file(file, SIGNATURE_LENGTH)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Reads the whole contents of the file. Returns nil when the file cannot be
|
|
168
|
+
# read.
|
|
169
|
+
def file_content(file)
|
|
170
|
+
read_file(file)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Reads the contents of the file, or only its leading bytes when a maximum
|
|
174
|
+
# length is given.
|
|
175
|
+
def read_file(file, max_length = nil)
|
|
176
|
+
if uploaded_file?(file)
|
|
177
|
+
File.open(file.path, "rb") { |io| read_io(io, max_length) }
|
|
178
|
+
elsif file.is_a?(ActiveStorage::Attached)
|
|
179
|
+
read_attached(file, max_length)
|
|
180
|
+
end
|
|
181
|
+
rescue ActiveStorage::Error, Errno::ENOENT, IOError
|
|
182
|
+
nil
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Reads the contents of an IO, or only its leading bytes when a maximum
|
|
186
|
+
# length is given. IO#read returns nil at the end of the file, so an empty
|
|
187
|
+
# file would otherwise be indistinguishable from an unreadable one and skip
|
|
188
|
+
# the validation. Normalizing it to an empty content keeps empty files
|
|
189
|
+
# rejected, while nil is kept for files which cannot be read at all.
|
|
190
|
+
def read_io(io, max_length = nil)
|
|
191
|
+
(max_length ? io.read(max_length) : io.read) || ""
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Reads the contents of an attached file. Blobs are only uploaded once the
|
|
195
|
+
# record is saved, so for still unpersisted blobs (e.g. an image assigned to
|
|
196
|
+
# a new record) the bytes are read from the pending attachable. Otherwise a
|
|
197
|
+
# spoofed image could be saved without being checked.
|
|
198
|
+
def read_attached(attached, max_length = nil)
|
|
199
|
+
blob = attached.blob
|
|
200
|
+
return read_blob(blob, max_length) if blob&.persisted?
|
|
201
|
+
|
|
202
|
+
read_pending_attachable(attached, max_length)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# ActiveStorage keeps the attachable of a pending attachment in the record's
|
|
206
|
+
# attachment changes until the blob is uploaded when the record is saved, so
|
|
207
|
+
# its contents can already be read during the validation.
|
|
208
|
+
def read_pending_attachable(attached, max_length = nil)
|
|
209
|
+
attachable = pending_attachable(attached)
|
|
210
|
+
if uploaded_file?(attachable) || attachable.is_a?(File)
|
|
211
|
+
File.open(attachable.path, "rb") { |io| read_io(io, max_length) }
|
|
212
|
+
elsif attachable.is_a?(Pathname)
|
|
213
|
+
File.open(attachable.to_path, "rb") { |io| read_io(io, max_length) }
|
|
214
|
+
elsif attachable.is_a?(Hash)
|
|
215
|
+
read_io_without_consuming(attachable[:io], max_length)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def pending_attachable(attached)
|
|
220
|
+
change = attached.record.try(:attachment_changes)&.[](attached.name.to_s)
|
|
221
|
+
change.try(:attachable)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Reads the contents without consuming the IO, so ActiveStorage can still
|
|
225
|
+
# upload it after the validation.
|
|
226
|
+
def read_io_without_consuming(io, max_length = nil)
|
|
227
|
+
return unless io.respond_to?(:read) && io.respond_to?(:rewind)
|
|
228
|
+
|
|
229
|
+
io.rewind
|
|
230
|
+
content = read_io(io, max_length)
|
|
231
|
+
io.rewind
|
|
232
|
+
content
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Reads the whole contents of the blob, or only its leading bytes when a
|
|
236
|
+
# maximum length is given to keep the operation cheap for large files. The
|
|
237
|
+
# services return nil when the blob is empty, which is normalized to an
|
|
238
|
+
# empty content so that empty blobs are rejected. Falls back to opening the
|
|
239
|
+
# whole blob when the service does not support ranged downloads.
|
|
240
|
+
def read_blob(blob, max_length = nil)
|
|
241
|
+
return blob.download if max_length.nil?
|
|
242
|
+
|
|
243
|
+
blob.download_chunk(0...max_length) || ""
|
|
244
|
+
rescue NotImplementedError
|
|
245
|
+
blob.open { |io| read_io(io, max_length) }
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# The image format detected from the file signature, or nil when the
|
|
249
|
+
# signature does not match any of the supported image formats.
|
|
250
|
+
def image_format(signature)
|
|
251
|
+
return nil if signature.blank?
|
|
252
|
+
|
|
253
|
+
binary_image_format(signature) || ftyp_image_format(signature) || svg_format(signature)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def binary_image_format(signature)
|
|
257
|
+
BINARY_IMAGE_SIGNATURES.find do |_format, pairs|
|
|
258
|
+
pairs.all? { |offset, bytes| signature[offset, bytes.bytesize] == bytes }
|
|
259
|
+
end&.first
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# The format of an ISOBMFF-based image (HEIF or AVIF). These files start with
|
|
263
|
+
# a "ftyp" box at offset 4 followed by a major brand at offset 8.
|
|
264
|
+
def ftyp_image_format(signature)
|
|
265
|
+
return nil unless signature[4, 4] == "ftyp".b
|
|
266
|
+
|
|
267
|
+
FTYPE_IMAGE_BRANDS.find { |_format, brands| brands.include?(signature[8, 4]) }&.first
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def svg_format(signature)
|
|
271
|
+
content = signature.sub(/\A\xEF\xBB\xBF/n, "").lstrip
|
|
272
|
+
return nil unless SVG_SIGNATURES.any? { |svg_signature| content.start_with?(svg_signature) }
|
|
273
|
+
|
|
274
|
+
:svg
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def uploaded_file?(file)
|
|
278
|
+
return true if defined?(Rack::Test::UploadedFile) && file.is_a?(Rack::Test::UploadedFile)
|
|
279
|
+
|
|
280
|
+
file.is_a?(ActionDispatch::Http::UploadedFile)
|
|
281
|
+
end
|
|
282
|
+
end
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</label>
|
|
13
13
|
|
|
14
14
|
<div data-controller="accordion" class="radio-accordion-section content-block__description editor-content">
|
|
15
|
-
<div id="panel-title--<%= panel_id %>" aria-hidden="true">
|
|
15
|
+
<div id="panel-title--<%= panel_id %>" aria-hidden="true" inert>
|
|
16
16
|
<%= yield %>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
<%= show_more_text %>
|
|
22
22
|
</span>
|
|
23
23
|
<%= icon "arrow-down-s-line" %>
|
|
24
|
-
<span>
|
|
25
|
-
<%= show_less_text %>
|
|
26
|
-
</span>
|
|
27
|
-
<%= icon "arrow-up-s-line" %>
|
|
28
24
|
</button>
|
|
29
25
|
</div>
|
|
30
26
|
</div>
|
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
1
|
+
<%
|
|
2
|
+
manifest = {
|
|
3
|
+
name: organization_params.html_name,
|
|
4
|
+
short_name: organization_params.html_short_name,
|
|
5
|
+
lang: organization_params.default_locale,
|
|
6
|
+
description: organization_params.translated_description,
|
|
7
|
+
display: organization_params.pwa_display,
|
|
8
|
+
start_url: organization_params.start_url,
|
|
9
|
+
theme_color: organization_params.colors["primary"],
|
|
10
|
+
background_color: "#FFFFFF",
|
|
11
|
+
icons: [
|
|
11
12
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
src: current_organization.attached_uploader(:favicon).variant_url(:small),
|
|
14
|
+
sizes: "32x32",
|
|
15
|
+
type: "image/png"
|
|
15
16
|
},
|
|
16
17
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
src: current_organization.attached_uploader(:favicon).variant_url(:medium),
|
|
19
|
+
sizes: "180x180",
|
|
20
|
+
type: "image/png"
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
src: current_organization.attached_uploader(:favicon).variant_url(:big),
|
|
24
|
+
sizes: "192x192",
|
|
25
|
+
type: "image/png"
|
|
25
26
|
},
|
|
26
27
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
src: current_organization.attached_uploader(:favicon).variant_url(:huge),
|
|
29
|
+
sizes: "512x512",
|
|
30
|
+
type: "image/png"
|
|
30
31
|
}
|
|
31
32
|
]
|
|
32
33
|
}
|
|
34
|
+
%>
|
|
35
|
+
<%== manifest.to_json %>
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
$("div[data-add-message]").replaceWith("<%= j(render "reply", form:, conversation:).html_safe %>");
|
|
3
|
-
window.initFoundation($("#new_message_"));
|
|
1
|
+
window.location.href = "<%= conversation_path(conversation) %>";
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
%>
|
|
10
10
|
|
|
11
11
|
<%= decidim_form_for(Decidim::User.new, namespace: "login", as: :user, url: path, html: { class: nil }) do |f| %>
|
|
12
|
-
<div>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<h3 id="dialog-title-loginModal" class="h3 ml-1"><%= t(".please_log_in") %></h3>
|
|
16
|
-
</div>
|
|
12
|
+
<div data-dialog-container>
|
|
13
|
+
<%= icon "user-line" %>
|
|
14
|
+
<h3 id="dialog-title-loginModal" tabindex="-1" data-dialog-title><%= t(".please_log_in") %></h3>
|
|
17
15
|
|
|
18
16
|
<div>
|
|
19
17
|
<% if current_organization.sign_in_enabled? %>
|
|
@@ -44,16 +42,16 @@
|
|
|
44
42
|
<%= render partial: "decidim/devise/shared/omniauth_buttons", locals: { is_horizontal: true } %>
|
|
45
43
|
<% end %>
|
|
46
44
|
<% end %>
|
|
47
|
-
<% if current_organization.sign_in_enabled? %>
|
|
48
|
-
<div data-dialog-actions>
|
|
49
|
-
<div class="form__wrapper-block w-full mb-4">
|
|
50
|
-
<button type="submit" class="button button__lg button__secondary">
|
|
51
|
-
<%= t("devise.sessions.new.log_in") %>
|
|
52
|
-
</button>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
<% end %>
|
|
56
45
|
</div>
|
|
57
46
|
</div>
|
|
47
|
+
<% if current_organization.sign_in_enabled? %>
|
|
48
|
+
<div data-dialog-actions>
|
|
49
|
+
<div class="form__wrapper-block w-full mb-4">
|
|
50
|
+
<button type="submit" class="button button__lg button__secondary">
|
|
51
|
+
<%= t("devise.sessions.new.log_in") %>
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<% end %>
|
|
58
56
|
<% end %>
|
|
59
57
|
<% end %>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<% Decidim::Paginable::OPTIONS.each do |per_page_option| %>
|
|
14
14
|
<li role="presentation">
|
|
15
15
|
<%= link_to per_page_option,
|
|
16
|
-
url_for(params
|
|
16
|
+
url_for(decidim_url_params(params, page: nil, per_page: per_page_option).except("locale", :locale)),
|
|
17
17
|
data: { per_page_option: },
|
|
18
18
|
class: "dropdown__item",
|
|
19
19
|
title: t("decidim.shared.results_per_page.title"),
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<% if organization.logo.attached? %>
|
|
9
9
|
<%= image_tag(
|
|
10
10
|
organization.attached_uploader(:logo).variant_url(:medium, host: organization.host),
|
|
11
|
-
style: "max-height: 50px",
|
|
11
|
+
style: "max-height: 50px; display: inline-block",
|
|
12
12
|
alt: organization_name(organization)
|
|
13
13
|
) %>
|
|
14
14
|
<% else %>
|
|
@@ -34,6 +34,16 @@ if Rails.env.production? || Rails.env.test?
|
|
|
34
34
|
Rack::Attack.throttle("limit password recovery attempts per email", limit: 5, period: 60.seconds) do |request|
|
|
35
35
|
request.params["user"]["email"] if request.path == "/users/password" && request.post?
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
# Throttle SMS verification confirmation attempts per IP to 10 reqs/minute
|
|
39
|
+
Rack::Attack.throttle("limit sms verification attempts per ip", limit: 10, period: 60.seconds) do |request|
|
|
40
|
+
request.ip if request.path.match?(%r{^/[^/]+/sms/authorizations(?:\.[^/]+)?$}) && request.put?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Throttle postal letter verification confirmation attempts per IP to 10 reqs/minute
|
|
44
|
+
Rack::Attack.throttle("limit postal letter verification attempts per ip", limit: 10, period: 60.seconds) do |request|
|
|
45
|
+
request.ip if request.path.match?(%r{^/[^/]+/postal_letter/authorizations(?:\.[^/]+)?$}) && request.put?
|
|
46
|
+
end
|
|
37
47
|
end
|
|
38
48
|
end
|
|
39
49
|
end
|
data/config/locales/bg.yml
CHANGED
|
@@ -82,8 +82,6 @@ bg:
|
|
|
82
82
|
decidim_with_month_name_short: "%d %b"
|
|
83
83
|
help:
|
|
84
84
|
date_format: 'Формат: дд/мм/гггг'
|
|
85
|
-
order: d-m-y
|
|
86
|
-
separator: "/"
|
|
87
85
|
datetime:
|
|
88
86
|
distance_in_words:
|
|
89
87
|
about_x_hours:
|
|
@@ -1508,7 +1506,6 @@ bg:
|
|
|
1508
1506
|
layouts:
|
|
1509
1507
|
decidim:
|
|
1510
1508
|
announcements:
|
|
1511
|
-
view_less: Покажи по-малко
|
|
1512
1509
|
view_more: Още информация
|
|
1513
1510
|
data_consent:
|
|
1514
1511
|
details:
|
|
@@ -1685,7 +1682,7 @@ bg:
|
|
|
1685
1682
|
long_with_particles: "%B %d, %Y от %H:%M"
|
|
1686
1683
|
short: "%d/%m/%Y %H:%M"
|
|
1687
1684
|
time_of_day: "%H:%M"
|
|
1688
|
-
tooltip: "%d-%m-%Y %H:%M %
|
|
1685
|
+
tooltip: "%d-%m-%Y %H:%M %Z (GMT %:z)"
|
|
1689
1686
|
versions:
|
|
1690
1687
|
directions:
|
|
1691
1688
|
left: Изтривания
|
data/config/locales/ca-IT.yml
CHANGED
|
@@ -118,8 +118,6 @@ ca-IT:
|
|
|
118
118
|
decidim_with_month_name_short: "%d %b"
|
|
119
119
|
help:
|
|
120
120
|
date_format: 'Format: dd/mm/aaaa'
|
|
121
|
-
order: d-m-y
|
|
122
|
-
separator: "/"
|
|
123
121
|
datetime:
|
|
124
122
|
distance_in_words:
|
|
125
123
|
about_x_hours:
|
|
@@ -253,6 +251,7 @@ ca-IT:
|
|
|
253
251
|
create: "%{user_name} ha afegit el component %{resource_name} a l'espai %{space_name}"
|
|
254
252
|
delete: "%{user_name} ha eliminat el component %{resource_name} de l'espai %{space_name}"
|
|
255
253
|
export_component: "%{user_name} ha exportat %{resource_name}%{component_name} de %{space_name} com %{format_name}"
|
|
254
|
+
menu_hidden: "%{user_name} ha amagat el component %{resource_name} del menú de l'espai de participació: %{space_name}"
|
|
256
255
|
publish: "%{user_name} ha publicat el component %{resource_name} a l'espai %{space_name}"
|
|
257
256
|
restore: "%{user_name} ha restaurat el component %{resource_name} a l'espai %{space_name}"
|
|
258
257
|
soft_delete: "%{user_name} ha mogut el component %{resource_name} a l'espai %{space_name} a la paperera"
|
|
@@ -857,6 +856,8 @@ ca-IT:
|
|
|
857
856
|
errors:
|
|
858
857
|
files:
|
|
859
858
|
file_cannot_be_processed: No s'ha pogut processar el fitxer
|
|
859
|
+
file_contains_unsafe_content: El fitxer conté contingut no segur
|
|
860
|
+
file_is_not_a_valid_image: El fitxer no és una imatge vàlida
|
|
860
861
|
file_resolution_too_large: La resolució de l'arxiu és massa gran
|
|
861
862
|
not_inside_organization: L'arxiu no està vinculat a cap organització.
|
|
862
863
|
internal_server_error:
|
|
@@ -2064,7 +2065,6 @@ ca-IT:
|
|
|
2064
2065
|
layouts:
|
|
2065
2066
|
decidim:
|
|
2066
2067
|
announcements:
|
|
2067
|
-
view_less: Mostra menys
|
|
2068
2068
|
view_more: Més informació
|
|
2069
2069
|
data_consent:
|
|
2070
2070
|
details:
|
|
@@ -2240,6 +2240,7 @@ ca-IT:
|
|
|
2240
2240
|
close: Tancar
|
|
2241
2241
|
reset: Reiniciar
|
|
2242
2242
|
select: Seleccionar
|
|
2243
|
+
clock_format: 24
|
|
2243
2244
|
formats:
|
|
2244
2245
|
day_of_month: "%b %d"
|
|
2245
2246
|
day_of_week: "%a"
|
|
@@ -2248,6 +2249,8 @@ ca-IT:
|
|
|
2248
2249
|
ddmm: "%d.%m"
|
|
2249
2250
|
ddmmyyyy: "%d.%m.%Y"
|
|
2250
2251
|
decidim_day_of_year: "%d %B %Y"
|
|
2252
|
+
decidim_month: "%B"
|
|
2253
|
+
decidim_month_and_year: "%B %Y"
|
|
2251
2254
|
decidim_short: "%d/%m/%Y %H:%M"
|
|
2252
2255
|
default: "%a, %d %b %Y %H:%M:%S %z"
|
|
2253
2256
|
devise:
|
|
@@ -2261,7 +2264,8 @@ ca-IT:
|
|
|
2261
2264
|
long_with_particles: "%d %B, de %Y a les %H:%M"
|
|
2262
2265
|
short: "%d/%m/%Y %H:%M"
|
|
2263
2266
|
time_of_day: "%H:%M"
|
|
2264
|
-
|
|
2267
|
+
time_of_day_with_time_zone: "%Z de %H:%M"
|
|
2268
|
+
tooltip: "%d-%m-%Y %H:%M %Z (GMT %:z)"
|
|
2265
2269
|
versions:
|
|
2266
2270
|
directions:
|
|
2267
2271
|
left: Esborrats
|
data/config/locales/ca.yml
CHANGED
|
@@ -118,8 +118,6 @@ ca:
|
|
|
118
118
|
decidim_with_month_name_short: "%d %b"
|
|
119
119
|
help:
|
|
120
120
|
date_format: 'Format: dd/mm/aaaa'
|
|
121
|
-
order: d-m-y
|
|
122
|
-
separator: "/"
|
|
123
121
|
datetime:
|
|
124
122
|
distance_in_words:
|
|
125
123
|
about_x_hours:
|
|
@@ -130,8 +128,8 @@ ca:
|
|
|
130
128
|
other: al voltant de %{count} mesos
|
|
131
129
|
half_a_minute: mig minut
|
|
132
130
|
less_than_x_minutes:
|
|
133
|
-
one:
|
|
134
|
-
other:
|
|
131
|
+
one: menys d'un minut
|
|
132
|
+
other: menys de %{count} minuts
|
|
135
133
|
less_than_x_seconds:
|
|
136
134
|
one: fa menys d'un segon
|
|
137
135
|
other: fa menys de %{count} segons
|
|
@@ -253,6 +251,7 @@ ca:
|
|
|
253
251
|
create: "%{user_name} ha afegit el component %{resource_name} a l'espai %{space_name}"
|
|
254
252
|
delete: "%{user_name} ha eliminat el component %{resource_name} de l'espai %{space_name}"
|
|
255
253
|
export_component: "%{user_name} ha exportat %{resource_name}%{component_name} de %{space_name} com %{format_name}"
|
|
254
|
+
menu_hidden: "%{user_name} ha amagat el component %{resource_name} del menú de l'espai de participació: %{space_name}"
|
|
256
255
|
publish: "%{user_name} ha publicat el component %{resource_name} a l'espai %{space_name}"
|
|
257
256
|
restore: "%{user_name} ha restaurat el component %{resource_name} a l'espai %{space_name}"
|
|
258
257
|
soft_delete: "%{user_name} ha mogut el component %{resource_name} a l'espai %{space_name} a la paperera"
|
|
@@ -857,6 +856,8 @@ ca:
|
|
|
857
856
|
errors:
|
|
858
857
|
files:
|
|
859
858
|
file_cannot_be_processed: No s'ha pogut processar el fitxer
|
|
859
|
+
file_contains_unsafe_content: El fitxer conté contingut no segur
|
|
860
|
+
file_is_not_a_valid_image: El fitxer no és una imatge vàlida
|
|
860
861
|
file_resolution_too_large: La resolució de l'arxiu és massa gran
|
|
861
862
|
not_inside_organization: L'arxiu no està vinculat a cap organització.
|
|
862
863
|
internal_server_error:
|
|
@@ -2064,7 +2065,6 @@ ca:
|
|
|
2064
2065
|
layouts:
|
|
2065
2066
|
decidim:
|
|
2066
2067
|
announcements:
|
|
2067
|
-
view_less: Mostra menys
|
|
2068
2068
|
view_more: Més informació
|
|
2069
2069
|
data_consent:
|
|
2070
2070
|
details:
|
|
@@ -2240,6 +2240,7 @@ ca:
|
|
|
2240
2240
|
close: Tancar
|
|
2241
2241
|
reset: Reiniciar
|
|
2242
2242
|
select: Seleccionar
|
|
2243
|
+
clock_format: 24
|
|
2243
2244
|
formats:
|
|
2244
2245
|
day_of_month: "%b %d"
|
|
2245
2246
|
day_of_week: "%a"
|
|
@@ -2248,6 +2249,8 @@ ca:
|
|
|
2248
2249
|
ddmm: "%d.%m"
|
|
2249
2250
|
ddmmyyyy: "%d.%m.%Y"
|
|
2250
2251
|
decidim_day_of_year: "%d %B %Y"
|
|
2252
|
+
decidim_month: "%B"
|
|
2253
|
+
decidim_month_and_year: "%B %Y"
|
|
2251
2254
|
decidim_short: "%d/%m/%Y %H:%M"
|
|
2252
2255
|
default: "%a, %d %b %Y %H:%M:%S %z"
|
|
2253
2256
|
devise:
|
|
@@ -2261,7 +2264,8 @@ ca:
|
|
|
2261
2264
|
long_with_particles: "%d %B, de %Y a les %H:%M"
|
|
2262
2265
|
short: "%d/%m/%Y %H:%M"
|
|
2263
2266
|
time_of_day: "%H:%M"
|
|
2264
|
-
|
|
2267
|
+
time_of_day_with_time_zone: "%H:%M %Z"
|
|
2268
|
+
tooltip: "%d-%m-%Y %H:%M %Z (GMT %:z)"
|
|
2265
2269
|
versions:
|
|
2266
2270
|
directions:
|
|
2267
2271
|
left: Esborrats
|