fix build error

(cherry picked from commit 1b1ea35ac9a50305bbfb9f0cdb846a556c50e05b)
This commit is contained in:
lyn1001 2022-02-09 18:45:03 +08:00 committed by openeuler-sync-bot
parent 220e8035a1
commit bf398184bd
3 changed files with 72 additions and 2 deletions

36
Fix-build-error.patch Normal file
View File

@ -0,0 +1,36 @@
From 39d75899dceb37a2a9d4bcd8beec980b60e248f0 Mon Sep 17 00:00:00 2001
From: Andreas Schwarz <andreas@andreas-s.net>
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)
"<img src=\"https://chart.googleapis.com/chart?cht=tx&chl=#{encoded_string}\" />"
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"

View File

@ -0,0 +1,27 @@
From 74f71ccf296c2b01e1a8455b4107b02316a7c7fb Mon Sep 17 00:00:00 2001
From: Peter Zhang <zpregister@gmail.com>
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!(/<!--(.|\s)*?-->/,"")
+ ret.gsub!(/<!--(.|\s)*?-->/,"") unless ret.frozen?
count = 0
tag_attr = key_options.collect { |p|
if p.instance_of?(Hash)

View File

@ -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 <liyanan32@huawei.com> - 0.8.0-2
- Fix build error
* Sat Aug 8 2020 yanan li <liyanan032@huawei.com> - 0.8.0-1
- Package init