From b807af1a405596390f6d09f729d16d68f45b67d3 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Thu, 12 Dec 2024 09:36:38 +0100 Subject: [PATCH] Remove `iconv` conditional require Drop legacy character encoding support for Ruby versions prior to 1.9, as string encoding is now natively supported in modern Ruby versions. --- CHANGELOG.md | 2 ++ lib/css_parser.rb | 1 - lib/css_parser/parser.rb | 7 +------ 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa59626..e003748 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Unreleased +* Remove `iconv` conditional require + ### Version v1.19.1 * Fix error when parsing values consisting of `!important` only diff --git a/lib/css_parser.rb b/lib/css_parser.rb index b50f81b..2fbbd20 100644 --- a/lib/css_parser.rb +++ b/lib/css_parser.rb @@ -6,7 +6,6 @@ require 'digest/md5' require 'zlib' require 'stringio' -require 'iconv' unless String.method_defined?(:encode) require 'css_parser/version' require 'css_parser/rule_set' diff --git a/lib/css_parser/parser.rb b/lib/css_parser/parser.rb index 11dd36f..e199e3b 100644 --- a/lib/css_parser/parser.rb +++ b/lib/css_parser/parser.rb @@ -677,12 +677,7 @@ def read_remote_file(uri) # :nodoc: end if charset - if String.method_defined?(:encode) - src.encode!('UTF-8', charset) - else - ic = Iconv.new('UTF-8//IGNORE', charset) - src = ic.iconv(src) - end + src.encode!('UTF-8', charset) end rescue @redirect_count = nil