summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2023-04-12 20:48:55 +0200
committerGitHub <[email protected]>2023-04-12 20:48:55 +0200
commit030d89000d957b4682dc159d008b2fdd378e9e6e (patch)
treed90bd0e8e572ac4a1acf341fd59619f9bec436cb
parent79c2802f94b3a2ee7ba7470ac7f0d3ffbd92ea0a (diff)
parentb5546e784c91e35b447793d624028e2d520392a6 (diff)
downloadcaxlsx-030d89000d957b4682dc159d008b2fdd378e9e6e.tar.gz
caxlsx-030d89000d957b4682dc159d008b2fdd378e9e6e.zip
Merge pull request #202 from kiskoza/release-candidate-3.4.0
Release candidate 3.4.0
-rw-r--r--CHANGELOG.md2
-rw-r--r--Gemfile1
-rw-r--r--lib/axlsx.rb2
-rw-r--r--lib/axlsx/util/mime_type_utils.rb6
-rw-r--r--lib/axlsx/version.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb2
-rw-r--r--test/drawing/tc_pic.rb5
-rw-r--r--test/tc_helper.rb1
-rw-r--r--test/util/tc_mime_type_utils.rb5
9 files changed, 20 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e6fa749..cc5cdd3a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
CHANGELOG
---------
- **Unreleased**
+
+- **April.12.23**: 3.4.0
- [PR #186](https://github.com/caxlsx/caxlsx/pull/186) - Add `escape_formulas` to global, workbook, worksheet, row and cell levels, and standardize behavior.
- [PR #186](https://github.com/caxlsx/caxlsx/pull/186) - `escape_formulas` should handle all [OWASP-designated formula prefixes](https://owasp.org/www-community/attacks/CSV_Injection).
- Fix bug when calling `worksheet.add_border("A1:B2", nil)`
diff --git a/Gemfile b/Gemfile
index 432b4503..fb69c977 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,7 @@ group :test do
gem 'rake'
gem 'simplecov', '>= 0.14.1'
gem 'test-unit'
+ gem 'webmock'
end
group :profile do
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index 9dba9144..0fd8260c 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -206,7 +206,7 @@ module Axlsx
# See https://www.owasp.org/index.php/CSV_Injection for details.
# @return [Boolean]
def self.escape_formulas
- @escape_formulas.nil? ? false : @escape_formulas
+ !defined?(@escape_formulas) || @escape_formulas.nil? ? false : @escape_formulas
end
# Sets whether to treat values starting with an equals sign as formulas or as literal strings.
diff --git a/lib/axlsx/util/mime_type_utils.rb b/lib/axlsx/util/mime_type_utils.rb
index 5a6ad38e..f0c3afb1 100644
--- a/lib/axlsx/util/mime_type_utils.rb
+++ b/lib/axlsx/util/mime_type_utils.rb
@@ -14,7 +14,11 @@ module Axlsx
# @param [String] v URI
# @return [String] File mime type
def self.get_mime_type_from_uri(v)
- Marcel::MimeType.for(URI.open(v))
+ if URI.respond_to?(:open)
+ Marcel::MimeType.for(URI.open(v))
+ else
+ Marcel::MimeType.for(URI.parse(v).open)
+ end
end
end
end
diff --git a/lib/axlsx/version.rb b/lib/axlsx/version.rb
index cf70e2e9..3f25c750 100644
--- a/lib/axlsx/version.rb
+++ b/lib/axlsx/version.rb
@@ -1,4 +1,4 @@
module Axlsx
# The current version
- VERSION = "3.3.0"
+ VERSION = "3.4.0"
end
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index 38fb5254..b4cad5be 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -21,7 +21,7 @@ module Axlsx
@sheet_protection = nil
initialize_page_options(options)
parse_options options
- self.escape_formulas = wb.escape_formulas if @escape_formulas.nil?
+ self.escape_formulas = wb.escape_formulas unless defined? @escape_formulas
@workbook.worksheets << self
@sheet_id = index + 1
yield self if block_given?
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb
index 34f24eb3..21d3f931 100644
--- a/test/drawing/tc_pic.rb
+++ b/test/drawing/tc_pic.rb
@@ -2,13 +2,16 @@ require 'tc_helper.rb'
class TestPic < Test::Unit::TestCase
def setup
+ stub_request(:get, 'https://example.com/sample-image.png')
+ .to_return(body: File.new('examples/sample.png'), status: 200)
+
@p = Axlsx::Package.new
ws = @p.workbook.add_worksheet
@test_img = @test_img_jpg = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
@test_img_png = File.dirname(__FILE__) + "/../fixtures/image1.png"
@test_img_gif = File.dirname(__FILE__) + "/../fixtures/image1.gif"
@test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg"
- @test_img_remote_png = "https://via.placeholder.com/150.png"
+ @test_img_remote_png = "https://example.com/sample-image.png"
@test_img_remote_fake = "invalid_URI"
@image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5
@image_remote = ws.add_image :image_src => @test_img_remote_png, remote: true, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5
diff --git a/test/tc_helper.rb b/test/tc_helper.rb
index af40a1e4..fb85870a 100644
--- a/test/tc_helper.rb
+++ b/test/tc_helper.rb
@@ -7,4 +7,5 @@ end
require 'test/unit'
require "timecop"
+require 'webmock/test_unit'
require "axlsx.rb"
diff --git a/test/util/tc_mime_type_utils.rb b/test/util/tc_mime_type_utils.rb
index 9d116931..52c49e2e 100644
--- a/test/util/tc_mime_type_utils.rb
+++ b/test/util/tc_mime_type_utils.rb
@@ -1,8 +1,11 @@
require 'tc_helper.rb'
class TestMimeTypeUtils < Test::Unit::TestCase
def setup
+ stub_request(:get, 'https://example.com/sample-image.png')
+ .to_return(body: File.new('examples/sample.png'), status: 200)
+
@test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
- @test_img_url = "https://via.placeholder.com/150.png"
+ @test_img_url = "https://example.com/sample-image.png"
end
def teardown