diff --git a/Gemfile b/Gemfile index bdef974ad4..1a2c225867 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,6 @@ gem 'sqlite3', '~> 1.4' gem 'feedjira' gem 'google-analytics-rails' -gem 'hpricot', '~>0.8.2' gem 'libxml-ruby', '~>5.0', require: 'libxml' gem 'uuid', '~>2.3' gem 'RedCloth', '>=4.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 3c61a30a24..b03a37d8c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -331,7 +331,6 @@ GEM hashdiff (1.0.1) hashie (3.6.0) highline (2.0.3) - hpricot (0.8.6) htmlentities (4.3.4) http-accept (1.7.0) http-cookie (1.0.5) @@ -517,6 +516,8 @@ GEM netrc (0.11.0) nio4r (2.7.4) nkf (0.2.0) + nokogiri (1.18.1-arm64-darwin) + racc (~> 1.4) nokogiri (1.18.1-x86_64-linux-gnu) racc (~> 1.4) nori (1.1.5) @@ -892,6 +893,7 @@ GEM actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) + sqlite3 (1.7.3-arm64-darwin) sqlite3 (1.7.3-x86_64-linux) stackprof (0.2.25) stringio (3.1.2) @@ -991,6 +993,7 @@ GEM rubyzip (~> 2.0.0) PLATFORMS + arm64-darwin-24 x86_64-linux DEPENDENCIES @@ -1042,7 +1045,6 @@ DEPENDENCIES gitlab_omniauth-ldap (~> 2.2.0) google-analytics-rails handlebars_assets - hpricot (~> 0.8.2) i18n-js indefinite_article jbuilder (~> 2.7) diff --git a/app/helpers/text_helper.rb b/app/helpers/text_helper.rb deleted file mode 100644 index 0d8d5e836b..0000000000 --- a/app/helpers/text_helper.rb +++ /dev/null @@ -1,54 +0,0 @@ -# By Henrik Nyh 2008-01-30. -# Free to modify and redistribute with credit. - -require 'rubygems' -require 'hpricot' - -module TextHelper - # Like the Rails _truncate_ helper but doesn't break HTML tags or entities. - def truncate_html(text, max_length = 30, ellipsis = '...') - return if text.nil? - - doc = Hpricot(text.to_s) - ellipsis_length = Hpricot(ellipsis).inner_text.length - content_length = doc.inner_text.length - actual_length = max_length - ellipsis_length - - content_length > max_length ? doc.truncate(actual_length).inner_html + ellipsis : text.to_s - end -end - -module HpricotTruncator - module NodeWithChildren - def truncate(max_length) - return self if inner_text.length <= max_length - truncated_node = dup - truncated_node.children = [] - each_child do |node| - remaining_length = max_length - truncated_node.inner_text.length - break if remaining_length == 0 - truncated_node.children << node.truncate(remaining_length) - end - truncated_node - end - end - - module TextNode - def truncate(max_length) - # We're using String#scan because Hpricot doesn't distinguish entities. - Hpricot::Text.new(content.scan(/&#?[^\W_]+;|./).first(max_length).join) - end - end - - module IgnoredTag - def truncate(_max_length) - self - end - end -end - -Hpricot::Doc.send(:include, HpricotTruncator::NodeWithChildren) -Hpricot::Elem.send(:include, HpricotTruncator::NodeWithChildren) -Hpricot::Text.send(:include, HpricotTruncator::TextNode) -Hpricot::BogusETag.send(:include, HpricotTruncator::IgnoredTag) -Hpricot::Comment.send(:include, HpricotTruncator::IgnoredTag)