From bf398184bdc60f3ae394b270fab8d0d85696769b Mon Sep 17 00:00:00 2001 From: lyn1001 Date: Wed, 9 Feb 2022 18:45:03 +0800 Subject: [PATCH] fix build error (cherry picked from commit 1b1ea35ac9a50305bbfb9f0cdb846a556c50e05b) --- Fix-build-error.patch | 36 +++++++++++++++++++ ...add-a-condition-to-avoid-FrozenError.patch | 27 ++++++++++++++ rubygem-wikicloth.spec | 11 ++++-- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 Fix-build-error.patch create mode 100644 rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch diff --git a/Fix-build-error.patch b/Fix-build-error.patch new file mode 100644 index 0000000..fa21e7c --- /dev/null +++ b/Fix-build-error.patch @@ -0,0 +1,36 @@ +From 39d75899dceb37a2a9d4bcd8beec980b60e248f0 Mon Sep 17 00:00:00 2001 +From: Andreas Schwarz +Date: Sat, 23 Jan 2021 23:17:53 +0100 +Subject: [PATCH] Remove URI.escape (deprecated in Ruby 3.0) + +--- + lib/wikicloth/extensions/math.rb | 2 +- + lib/wikicloth/wiki_buffer/var.rb | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/wikicloth/extensions/math.rb b/lib/wikicloth/extensions/math.rb +index 41dfef7..15a4c25 100644 +--- a/lib/wikicloth/extensions/math.rb ++++ b/lib/wikicloth/extensions/math.rb +@@ -34,7 +34,7 @@ class MathExtension < Extension + end + else + # if blahtex does not exist fallback to google charts api +- encoded_string = URI.escape(buffer.element_content, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) ++ encoded_string = URI.encode_www_form_component(buffer.element_content) + "" + end + end +diff --git a/lib/wikicloth/wiki_buffer/var.rb b/lib/wikicloth/wiki_buffer/var.rb +index 7a39527..1b392b8 100644 +--- a/lib/wikicloth/wiki_buffer/var.rb ++++ b/lib/wikicloth/wiki_buffer/var.rb +@@ -167,7 +167,7 @@ def default_functions(name,params) + @options[:params][params.first] = params[1] + "" + when "urlencode" +- URI.escape(params.first, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) ++ URI.encode_www_form_component(params.first) + when "lc" + params.first.downcase + when "uc" diff --git a/rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch b/rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch new file mode 100644 index 0000000..727dbf6 --- /dev/null +++ b/rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch @@ -0,0 +1,27 @@ +From 74f71ccf296c2b01e1a8455b4107b02316a7c7fb Mon Sep 17 00:00:00 2001 +From: Peter Zhang +Date: Sat, 21 Mar 2020 00:38:14 +0100 +Subject: add a condition to avoid FrozenError + +nil.to_s in Ruby 2.7.0 now always return a frozen String "" +a=nil.to_s +a.gsub!(//,'') +will raise a FrozenError (can't modify frozen String: "") +--- + lib/wikicloth/wiki_buffer/var.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/wikicloth/wiki_buffer/var.rb b/lib/wikicloth/wiki_buffer/var.rb +index 2e0f5d1..7a39527 100644 +--- a/lib/wikicloth/wiki_buffer/var.rb ++++ b/lib/wikicloth/wiki_buffer/var.rb +@@ -80,7 +80,7 @@ def to_html + + ret = @options[:link_handler].include_resource(key,key_options).to_s + +- ret.gsub!(//,"") ++ ret.gsub!(//,"") unless ret.frozen? + count = 0 + tag_attr = key_options.collect { |p| + if p.instance_of?(Hash) + diff --git a/rubygem-wikicloth.spec b/rubygem-wikicloth.spec index f4391ae..b32b795 100644 --- a/rubygem-wikicloth.spec +++ b/rubygem-wikicloth.spec @@ -1,15 +1,17 @@ %global gem_name wikicloth Name: rubygem-%{gem_name} Version: 0.8.0 -Release: 1 +Release: 2 Summary: Mediawiki parser License: MIT URL: https://github.com/nricciar/wikicloth Source0: https://rubygems.org/gems/wikicloth-%{version}.gem Patch0: rubygem-wikicloth-0.8.0-minitest.patch +Patch1: rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch +Patch2: Fix-build-error.patch Requires: ruby(release) ruby(rubygems) rubygem(builder) rubygem(expression_parser) BuildRequires: ruby(release) rubygems-devel rubygem(activesupport) rubygem(builder) -BuildRequires: rubygem(expression_parser) +BuildRequires: rubygem(expression_parser) rubygem(rexml) BuildArch: noarch Provides: rubygem(%{gem_name}) = %{version} %description @@ -27,6 +29,8 @@ gem unpack %{SOURCE0} %setup -q -D -T -n %{gem_name}-%{version} gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec %patch0 -p1 +%patch1 -p1 +%patch2 -p1 for f in .gitignore .travis.yml Gemfile Rakefile run_tests.rb tasks/wikicloth_tasks.rake; do rm $f sed -i "s|\"$f\".freeze,||g" %{gem_name}.gemspec @@ -65,5 +69,8 @@ popd %{gem_instdir}/sample_documents %changelog +* Wed Feb 9 2022 yanan li - 0.8.0-2 +- Fix build error + * Sat Aug 8 2020 yanan li - 0.8.0-1 - Package init