Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

fix(deps): update rails to 8.1.4.1, nokogiri, loofah and rails-html-sanitizer

Guido Boyke4448e25d65d1
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml
index baed24d..5ad0275 100644
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@ -458,6 +458,7 @@ jobs:
spec/requests/organisations/smart_folders_tenant_boundary_spec.rb
spec/services/tickets/subtask_counts_cache_spec.rb
spec/requests/organisations/smart_folders_visibility_spec.rb
+ spec/requests/organisations/smart_folders_item_preview_spec.rb
spec/requests/organisations/view_configurations_apply_columns_spec.rb
spec/requests/organisations/knowledge_spec.rb
spec/requests/organisations/knowledge_lane_spec.rb
diff --git a/CLAUDE.md b/CLAUDE.md
index 8080af3..5ac6b6f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -29,7 +29,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Build & Test Commands
-* **Runtime**: Ruby 4.0.7 (`.ruby-version`), Rails 8.1.4, `config.load_defaults 7.2`.
+* **Runtime**: Ruby 4.0.7 (`.ruby-version`), Rails 8.1.4.1, `config.load_defaults 7.2`.
CI reads Ruby from `.ruby-version`.
* **Development server**: **zwei Prozesse nötig** — `bin/dev` (Tailwind-Watch + Solid Queue via
diff --git a/Gemfile.lock b/Gemfile.lock
index 010d481..462be8c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -5,29 +5,29 @@ GEM
RedCloth (4.3.4)
action_text-trix (2.1.19)
railties
- actioncable (8.1.4)
- actionpack (= 8.1.4)
- activesupport (= 8.1.4)
+ actioncable (8.1.4.1)
+ actionpack (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
- actionmailbox (8.1.4)
- actionpack (= 8.1.4)
- activejob (= 8.1.4)
- activerecord (= 8.1.4)
- activestorage (= 8.1.4)
- activesupport (= 8.1.4)
+ actionmailbox (8.1.4.1)
+ actionpack (= 8.1.4.1)
+ activejob (= 8.1.4.1)
+ activerecord (= 8.1.4.1)
+ activestorage (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
mail (>= 2.8.0)
- actionmailer (8.1.4)
- actionpack (= 8.1.4)
- actionview (= 8.1.4)
- activejob (= 8.1.4)
- activesupport (= 8.1.4)
+ actionmailer (8.1.4.1)
+ actionpack (= 8.1.4.1)
+ actionview (= 8.1.4.1)
+ activejob (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
- actionpack (8.1.4)
- actionview (= 8.1.4)
- activesupport (= 8.1.4)
+ actionpack (8.1.4.1)
+ actionview (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
@@ -35,36 +35,36 @@ GEM
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
- actiontext (8.1.4)
+ actiontext (8.1.4.1)
action_text-trix (~> 2.1.15)
- actionpack (= 8.1.4)
- activerecord (= 8.1.4)
- activestorage (= 8.1.4)
- activesupport (= 8.1.4)
+ actionpack (= 8.1.4.1)
+ activerecord (= 8.1.4.1)
+ activestorage (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
- actionview (8.1.4)
- activesupport (= 8.1.4)
+ actionview (8.1.4.1)
+ activesupport (= 8.1.4.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
- rails-html-sanitizer (~> 1.6)
- activejob (8.1.4)
- activesupport (= 8.1.4)
+ rails-html-sanitizer (~> 1.6, >= 1.7.2)
+ activejob (8.1.4.1)
+ activesupport (= 8.1.4.1)
globalid (>= 0.3.6)
- activemodel (8.1.4)
- activesupport (= 8.1.4)
- activerecord (8.1.4)
- activemodel (= 8.1.4)
- activesupport (= 8.1.4)
+ activemodel (8.1.4.1)
+ activesupport (= 8.1.4.1)
+ activerecord (8.1.4.1)
+ activemodel (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
timeout (>= 0.4.0)
- activestorage (8.1.4)
- actionpack (= 8.1.4)
- activejob (= 8.1.4)
- activerecord (= 8.1.4)
- activesupport (= 8.1.4)
+ activestorage (8.1.4.1)
+ actionpack (= 8.1.4.1)
+ activejob (= 8.1.4.1)
+ activerecord (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
marcel (~> 1.0)
- activesupport (8.1.4)
+ activesupport (8.1.4.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -274,9 +274,9 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.6)
- loofah (2.25.2)
+ loofah (2.25.3)
crass (~> 1.0.2)
- nokogiri (>= 1.12.0)
+ nokogiri (>= 1.19.5)
lumberjack (1.2.10)
mail (2.9.1)
logger
@@ -322,24 +322,24 @@ GEM
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
- nokogiri (1.19.4)
+ nokogiri (1.19.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
- nokogiri (1.19.4-aarch64-linux-gnu)
+ nokogiri (1.19.7-aarch64-linux-gnu)
racc (~> 1.4)
- nokogiri (1.19.4-aarch64-linux-musl)
+ nokogiri (1.19.7-aarch64-linux-musl)
racc (~> 1.4)
- nokogiri (1.19.4-arm-linux-gnu)
+ nokogiri (1.19.7-arm-linux-gnu)
racc (~> 1.4)
- nokogiri (1.19.4-arm-linux-musl)
+ nokogiri (1.19.7-arm-linux-musl)
racc (~> 1.4)
- nokogiri (1.19.4-arm64-darwin)
+ nokogiri (1.19.7-arm64-darwin)
racc (~> 1.4)
- nokogiri (1.19.4-x86_64-darwin)
+ nokogiri (1.19.7-x86_64-darwin)
racc (~> 1.4)
- nokogiri (1.19.4-x86_64-linux-gnu)
+ nokogiri (1.19.7-x86_64-linux-gnu)
racc (~> 1.4)
- nokogiri (1.19.4-x86_64-linux-musl)
+ nokogiri (1.19.7-x86_64-linux-musl)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
@@ -401,20 +401,20 @@ GEM
rack (>= 1.3)
rackup (2.2.1)
rack (>= 3)
- rails (8.1.4)
- actioncable (= 8.1.4)
- actionmailbox (= 8.1.4)
- actionmailer (= 8.1.4)
- actionpack (= 8.1.4)
- actiontext (= 8.1.4)
- actionview (= 8.1.4)
- activejob (= 8.1.4)
- activemodel (= 8.1.4)
- activerecord (= 8.1.4)
- activestorage (= 8.1.4)
- activesupport (= 8.1.4)
+ rails (8.1.4.1)
+ actioncable (= 8.1.4.1)
+ actionmailbox (= 8.1.4.1)
+ actionmailer (= 8.1.4.1)
+ actionpack (= 8.1.4.1)
+ actiontext (= 8.1.4.1)
+ actionview (= 8.1.4.1)
+ activejob (= 8.1.4.1)
+ activemodel (= 8.1.4.1)
+ activerecord (= 8.1.4.1)
+ activestorage (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
bundler (>= 1.15.0)
- railties (= 8.1.4)
+ railties (= 8.1.4.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
@@ -423,15 +423,15 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
- rails-html-sanitizer (1.7.1)
- loofah (~> 2.25, >= 2.25.2)
+ rails-html-sanitizer (1.7.2)
+ loofah (~> 2.25, >= 2.25.3)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
rails-i18n (8.0.2)
i18n (>= 0.7, < 2)
railties (>= 8.0.0, < 9)
- railties (8.1.4)
- actionpack (= 8.1.4)
- activesupport (= 8.1.4)
+ railties (8.1.4.1)
+ actionpack (= 8.1.4.1)
+ activesupport (= 8.1.4.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
diff --git a/app/components/neo_tag_component.rb b/app/components/neo_tag_component.rb
index 7916ce8..9c5bcb8 100644
--- a/app/components/neo_tag_component.rb
+++ b/app/components/neo_tag_component.rb
@@ -78,9 +78,10 @@ class NeoTagComponent < ViewComponent::Base
end
# What the cross removes, by name: a row of chips is a row of buttons, and "Remove"
- # five times over tells a screen reader nothing.
+ # five times over tells a screen reader nothing. As text, because the template
+ # escapes the label: an entity in it would be read out as "&quot;".
def remove_label
- name = helpers.strip_tags(tag_content.to_s).squish
+ name = helpers.text_from_html(tag_content).squish
name.present? ? t('components.neo_tag.remove', name: name) : t('views.common.remove')
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 9ec4051..614fd5b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -738,4 +738,14 @@ module ApplicationHelper
def javascript_translations
{ stimulus: I18n.t('stimulus') }
end
+
+ # HTML as text, for a place that escapes what it writes: truncate, an attribute
+ # written with <%= %>, the value of a translation. strip_tags returns HTML: & < >
+ # as entities, " and ' as well since Rails 8.1.4.1, a no-break space as &nbsp;.
+ # Escaped once more, each would show as its entity. Reading the stripped text as
+ # a fragment decodes them all; CGI.unescapeHTML leaves &nbsp; standing. The
+ # result is a plain String, so markup in it is escaped wherever it is written.
+ def text_from_html(html)
+ Nokogiri::HTML5.fragment(strip_tags(html.to_s)).text
+ end
end
diff --git a/app/views/organisations/smart_folders/show.html.erb b/app/views/organisations/smart_folders/show.html.erb
index c77e03a..1396b61 100644
--- a/app/views/organisations/smart_folders/show.html.erb
+++ b/app/views/organisations/smart_folders/show.html.erb
@@ -99,7 +99,8 @@
<% if item.respond_to?(:description) && item.description.present? %>
<%= truncate(item.description, length: 150) %>
<% elsif item.respond_to?(:content) && item.content.present? %>
- <%= truncate(strip_tags(item.content.to_s), length: 150) %>
+ <%# As text: truncate escapes what it returns, and an entity would show as "&quot;". %>
+ <%= truncate(text_from_html(item.content), length: 150) %>
<% end %>
</div>
diff --git a/spec/components/neo_tag_component_spec.rb b/spec/components/neo_tag_component_spec.rb
index bdbafb8..521fd63 100644
--- a/spec/components/neo_tag_component_spec.rb
+++ b/spec/components/neo_tag_component_spec.rb
@@ -94,6 +94,14 @@ RSpec.describe NeoTagComponent, type: :component do
expect(page).to have_css("button.remove-button[aria-label='Anna Admin entfernen']")
end
+
+ # Since Rails 8.1.4.1 strip_tags writes quotes as entities too, and the template
+ # escapes the label once more: a reader heard "&quot;", and "&amp;" before that.
+ it 'names the button with quotes, ampersands and no-break spaces as they read' do
+ render_inline(described_class.new(removable: true)) { %q(<span>Werkstatt&nbsp;"Nord" &amp; Kim's</span>).html_safe }
+
+ expect(page.find('button.remove-button')['aria-label']).to eq(%q(Werkstatt "Nord" & Kim's entfernen))
+ end
end
context 'with href' do
diff --git a/spec/requests/organisations/smart_folders_item_preview_spec.rb b/spec/requests/organisations/smart_folders_item_preview_spec.rb
new file mode 100644
index 0000000..adbbd4c
--- /dev/null
+++ b/spec/requests/organisations/smart_folders_item_preview_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# What: the preview line under an item of a saved view, cut to 150 characters.
+# Why: strip_tags returns HTML, and since Rails 8.1.4.1 it writes " and ' as
+# entities as well. truncate escapes what it returns, so a long preview showed
+# "&quot;" and "&#39;" as text, and "&amp;" and "&nbsp;" before that already.
+RSpec.describe 'The preview line of an item in a saved view', :ci_guard, type: :request do
+ let(:organisation) { create(:organisation) }
+ let(:user) { create(:user) }
+ let(:project) { create(:project, organisation: organisation) }
+ let(:folder) do
+ create(:smart_folder, organisation: organisation, project: project, user: user, target_object_type: 'Note').tap do |view|
+ group = create(:smart_folder_rule_group, smart_folder: view)
+ create(:smart_folder_rule, smart_folder_rule_group: group, field: 'tag', operator: 'has', value: 'vorschau')
+ end
+ end
+
+ before do
+ ActsAsTenant.current_tenant = organisation
+ create(:membership, user: user, organisation: organisation, role: create(:admin_role, organisation: organisation), active: true)
+ sign_in user
+ end
+
+ after { ActsAsTenant.current_tenant = nil }
+
+ # Without a description, so the preview comes from the content. cut: long enough
+ # for truncate to cut it.
+ def note_with(text, cut:)
+ text += ' und mehr' * 20 if cut
+ note = create(:note, project: project, organisation: organisation, creator: user, description: nil,
+ content: "<p>#{text}</p>")
+ create(:tagging, tag: create(:tag, name: 'vorschau', organisation: organisation), taggable: note)
+ end
+
+ def folder_page
+ get organisation_smart_folder_path(organisation, folder)
+ expect(response).to have_http_status(:ok)
+ Capybara.string(response.body)
+ end
+
+ it 'shows quotes, ampersands and no-break spaces of a cut text as they are written' do
+ note_with(%q(Werkstatt&nbsp;"Nord" &amp; Kim's Plan), cut: true)
+
+ expect(folder_page.text).to match(/Werkstatt[[:space:]]"Nord" & Kim's Plan und mehr/)
+ expect(response.body).not_to include('&amp;quot;', '&amp;#39;', '&amp;amp;', '&amp;nbsp;')
+ end
+
+ # Uncut, because only a text that truncate leaves whole keeps a SafeBuffer: the
+ # decoded text marked html_safe would show up here as markup.
+ it 'shows markup that a text contains as text, not as markup' do
+ note_with('Ein &lt;b&gt;fettes&lt;/b&gt; Wort', cut: false)
+
+ html = folder_page
+ expect(html.text).to include('Ein <b>fettes</b> Wort')
+ expect(html).to have_no_css('b', text: 'fettes')
+ end
+end