decidim-core 0.26.5 → 0.26.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/announcement_cell.rb +1 -1
  3. data/app/cells/decidim/content_blocks/cta_cell.rb +1 -1
  4. data/app/cells/decidim/content_blocks/hero/show.erb +1 -1
  5. data/app/cells/decidim/content_blocks/highlighted_content_banner/show.erb +1 -1
  6. data/app/cells/decidim/content_blocks/sub_hero_cell.rb +1 -1
  7. data/app/controllers/decidim/links_controller.rb +8 -11
  8. data/app/helpers/decidim/cells_helper.rb +1 -0
  9. data/app/helpers/decidim/external_domain_helper.rb +14 -3
  10. data/app/helpers/decidim/sanitize_helper.rb +15 -5
  11. data/app/models/decidim/scope_type.rb +28 -0
  12. data/app/packs/src/decidim/editor/clipboard_override.js +6 -2
  13. data/app/packs/src/decidim/editor.js +63 -33
  14. data/app/packs/stylesheets/decidim/_editor.scss +129 -0
  15. data/app/packs/stylesheets/decidim/extras/_quill.scss +0 -6
  16. data/app/packs/stylesheets/decidim/modules/_buttons.scss +10 -6
  17. data/app/packs/stylesheets/decidim/modules/_cards.scss +1 -1
  18. data/app/packs/stylesheets/decidim/modules/_comments.scss +24 -0
  19. data/app/packs/stylesheets/decidim/vizzs/_linechart.scss +2 -2
  20. data/app/packs/stylesheets/decidim/vizzs/_rowchart.scss +2 -2
  21. data/app/presenters/decidim/notification_presenter.rb +1 -1
  22. data/app/presenters/decidim/user_group_presenter.rb +1 -1
  23. data/app/presenters/decidim/user_presenter.rb +1 -1
  24. data/app/scrubbers/decidim/admin_input_scrubber.rb +27 -0
  25. data/app/scrubbers/decidim/user_input_scrubber.rb +32 -5
  26. data/app/services/decidim/traceability.rb +1 -0
  27. data/app/views/decidim/links/_invalid_url_modal.html.erb +17 -0
  28. data/app/views/decidim/links/_modal.html.erb +1 -1
  29. data/app/views/decidim/links/invalid_url.js.erb +24 -0
  30. data/app/views/decidim/links/new.html.erb +1 -1
  31. data/app/views/decidim/messaging/conversations/_conversation.html.erb +1 -5
  32. data/app/views/decidim/pages/_standalone.html.erb +1 -1
  33. data/app/views/decidim/pages/_tabbed.html.erb +1 -1
  34. data/config/locales/ar.yml +422 -7
  35. data/config/locales/bg.yml +1 -4
  36. data/config/locales/ca.yml +20 -18
  37. data/config/locales/cs.yml +21 -29
  38. data/config/locales/da.yml +3 -0
  39. data/config/locales/de.yml +4 -23
  40. data/config/locales/el.yml +2 -4
  41. data/config/locales/en.yml +15 -13
  42. data/config/locales/eo.yml +2 -1
  43. data/config/locales/es-MX.yml +19 -17
  44. data/config/locales/es-PY.yml +19 -17
  45. data/config/locales/es.yml +20 -18
  46. data/config/locales/et.yml +3 -0
  47. data/config/locales/eu.yml +87 -63
  48. data/config/locales/fa-IR.yml +1 -0
  49. data/config/locales/fi-plain.yml +0 -19
  50. data/config/locales/fi.yml +17 -15
  51. data/config/locales/fr-CA.yml +22 -17
  52. data/config/locales/fr.yml +20 -15
  53. data/config/locales/ga-IE.yml +1 -0
  54. data/config/locales/gl.yml +0 -22
  55. data/config/locales/gn-PY.yml +3 -0
  56. data/config/locales/hr.yml +3 -0
  57. data/config/locales/hu.yml +48 -24
  58. data/config/locales/id-ID.yml +2 -4
  59. data/config/locales/is-IS.yml +2 -1
  60. data/config/locales/it.yml +1 -11
  61. data/config/locales/ja.yml +9 -23
  62. data/config/locales/ka-GE.yml +3 -0
  63. data/config/locales/kaa.yml +1 -0
  64. data/config/locales/lb.yml +0 -4
  65. data/config/locales/lt.yml +0 -33
  66. data/config/locales/lv.yml +0 -3
  67. data/config/locales/nl.yml +1 -20
  68. data/config/locales/no.yml +1 -24
  69. data/config/locales/oc-FR.yml +2 -0
  70. data/config/locales/pl.yml +0 -33
  71. data/config/locales/pt-BR.yml +2 -6
  72. data/config/locales/pt.yml +0 -4
  73. data/config/locales/ro-RO.yml +5 -8
  74. data/config/locales/ru.yml +1 -3
  75. data/config/locales/sk.yml +3 -5
  76. data/config/locales/sl.yml +1 -0
  77. data/config/locales/sr-CS.yml +2 -0
  78. data/config/locales/sv.yml +1 -24
  79. data/config/locales/tr-TR.yml +3 -7
  80. data/config/locales/uk.yml +1 -3
  81. data/config/locales/zh-CN.yml +0 -4
  82. data/config/locales/zh-TW.yml +1712 -0
  83. data/lib/decidim/core/test/shared_examples/comments_examples.rb +36 -0
  84. data/lib/decidim/core/test/shared_examples/editor_shared_examples.rb +10 -0
  85. data/lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb +7 -3
  86. data/lib/decidim/core/test.rb +1 -0
  87. data/lib/decidim/core/version.rb +1 -1
  88. data/lib/decidim/form_builder.rb +0 -1
  89. data/lib/decidim/publicable.rb +4 -0
  90. metadata +12 -6
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # Use this class as a scrubber to sanitize admin user input. The default
5
+ # scrubbed provided by Rails does not allow `iframe`s, and we are using
6
+ # them to embed videos, so we need to provide a whole new scrubber.
7
+ #
8
+ # Example:
9
+ #
10
+ # sanitize(@page.body, scrubber: Decidim::AdminInputScrubber.new)
11
+ #
12
+ # Lists of default tags and attributes are extracted from
13
+ # https://stackoverflow.com/a/35073814/2110884.
14
+ class AdminInputScrubber < UserInputScrubber
15
+ private
16
+
17
+ DECIDIM_ALLOWED_TAGS = %w(img video audio source comment iframe).freeze
18
+
19
+ def custom_allowed_attributes
20
+ super + %w(frameborder allowfullscreen) - %w(onerror)
21
+ end
22
+
23
+ def custom_allowed_tags
24
+ super + DECIDIM_ALLOWED_TAGS
25
+ end
26
+ end
27
+ end
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
- # Use this class as a scrubber to sanitize user input. The default
5
- # scrubbed provided by Rails does not allow `iframe`s, and we're using
6
- # them to embed videos, so we need to provide a whole new scrubber.
4
+ # Use this class as a scrubber to sanitize participant user input.
7
5
  #
8
6
  # Example:
9
7
  #
@@ -20,12 +18,41 @@ module Decidim
20
18
 
21
19
  private
22
20
 
21
+ RESTRICTED_TAGS = %w(
22
+ area
23
+ article
24
+ aside
25
+ audio
26
+ button
27
+ canvas
28
+ fieldset
29
+ figcaption
30
+ figure
31
+ font
32
+ footer
33
+ form
34
+ header
35
+ img
36
+ input
37
+ label
38
+ legend
39
+ main
40
+ map
41
+ menu
42
+ optgroup
43
+ option
44
+ output
45
+ select
46
+ textarea
47
+ video
48
+ ).freeze
49
+
23
50
  def custom_allowed_attributes
24
- Loofah::HTML5::SafeList::ALLOWED_ATTRIBUTES + %w(frameborder allowfullscreen) - %w(onerror)
51
+ Loofah::HTML5::SafeList::ALLOWED_ATTRIBUTES
25
52
  end
26
53
 
27
54
  def custom_allowed_tags
28
- Loofah::HTML5::SafeList::ALLOWED_ELEMENTS_WITH_LIBXML2 + %w(iframe)
55
+ Loofah::HTML5::SafeList::ACCEPTABLE_ELEMENTS - RESTRICTED_TAGS
29
56
  end
30
57
  end
31
58
  end
@@ -117,6 +117,7 @@ module Decidim
117
117
  return unless user.is_a?(Decidim::User)
118
118
  # If the record is not valid, it may not yet have an ID causing an
119
119
  # exception when trying to save the log record.
120
+ return if resource.nil?
120
121
  return unless resource.valid?
121
122
 
122
123
  Decidim::ActionLogger.log(
@@ -0,0 +1,17 @@
1
+ <%= decidim_modal id: "external-domain-warning" do %>
2
+ <div data-dialog-container>
3
+ <%= icon "external-link-line" %>
4
+ <h2 id="dialog-title-external-domain-warning" tabindex="-1" data-dialog-title><%= t("decidim.links.warning.title") %></h2>
5
+ <div>
6
+
7
+ <code class="mt-5 block break-all text-alert">
8
+ <%= flash[:alert] %>
9
+ </code>
10
+ </div>
11
+ </div>
12
+ <div data-dialog-actions>
13
+ <button class="button button__lg button__transparent-secondary" data-dialog-close="external-domain-warning">
14
+ <%= t("decidim.links.warning.cancel") %>
15
+ </button>
16
+ </div>
17
+ <% end %>
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
  </div>
15
15
  <div class="row buttons">
16
- <%= link_to t("decidim.links.warning.proceed"), params[:external_url], target: "_blank", data: { close: "" }, class: "button primary button--nomargin" %>
16
+ <%= link_to t("decidim.links.warning.proceed"), external_url.to_s, target: "_blank", data: { close: "" }, class: "button primary button--nomargin" %>
17
17
  <button class="button clear" data-close>
18
18
  <%= t("decidim.links.warning.cancel") %>
19
19
  </button>
@@ -0,0 +1,24 @@
1
+ (function() {
2
+ const create = (selector) => {
3
+ const element = document.createElement("div")
4
+ element.id = selector
5
+ document.body.append(element)
6
+ return element
7
+ }
8
+
9
+ const selector = "external-domain-warning"
10
+ const selectorContainer = `${selector}-container`
11
+
12
+ // if the container does not exist in the DOM, it creates a new one, otherwise, replace the content
13
+ const externalDomainWarning = document.getElementById(selectorContainer) || create(selectorContainer)
14
+
15
+ externalDomainWarning.innerHTML = ''
16
+ externalDomainWarning.innerHTML = '<%= j(render partial: "invalid_url_modal").strip.html_safe %>'
17
+
18
+ new window.Decidim.Dialogs(`#${selector}`, {
19
+ closingSelector: `[data-dialog-close="${selector}"]`,
20
+ backdropSelector: `[data-dialog="${selector}"]`,
21
+ labelledby: `dialog-title-${selector}`,
22
+ describedby: `dialog-desc-${selector}`
23
+ }).open()
24
+ })()
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
  <div class="row">
14
14
  <div class="columns large-12 text-center">
15
- <%= link_to t("decidim.links.warning.proceed"), params[:external_url], class: "button expanded primary" %>
15
+ <%= link_to t("decidim.links.warning.proceed"), external_url.to_s, class: "button expanded primary" %>
16
16
  </div>
17
17
  </div>
18
18
  </div>
@@ -33,11 +33,7 @@
33
33
  <span class="text-small">
34
34
  <%= t("last_message", scope: "decidim.messaging.conversations.index") %>:
35
35
  <strong>
36
- <% if I18n.locale != :en %>
37
- <%= t("ago", scope: "decidim.messaging.conversations.index") %> <%= time_ago_in_words(Time.parse(conversation.last_message.created_at.to_s)) %>
38
- <% else %>
39
- <%= time_ago_in_words(Time.parse(conversation.last_message.created_at.to_s)) %> <%= t("ago", scope: "decidim.messaging.conversations.index") %>
40
- <% end %>
36
+ <%= t("decidim.user_conversations.index.time_ago", time: time_ago_in_words(Time.zone.parse(conversation.last_message.created_at.to_s))) %>
41
37
  </strong>
42
38
  </span>
43
39
  </div>
@@ -10,7 +10,7 @@
10
10
 
11
11
  <div class="columns small-12">
12
12
  <div class="card">
13
- <div class="card__content"><%= decidim_sanitize translated_attribute page.content %></div>
13
+ <div class="card__content"><%= decidim_sanitize_editor_admin translated_attribute page.content %></div>
14
14
  </div>
15
15
  </div>
16
16
 
@@ -32,7 +32,7 @@
32
32
  <h2>
33
33
  <%= translated_attribute page.title %>
34
34
  </h2>
35
- <%= decidim_sanitize_editor translated_attribute page.content %>
35
+ <%= decidim_sanitize_editor_admin translated_attribute page.content %>
36
36
  </div>
37
37
  </div>
38
38
  </div>