mirror of
https://github.com/discourse/discourse.git
synced 2025-06-10 05:23:44 +08:00
FIX: do not raise exception when svg path is nil (#13844)
Bug was introduced here: f7ab852e12
If path is nil, it should not raise an exception and continue logging the error.
This commit is contained in:

committed by
GitHub

parent
6db93e86d4
commit
88aa0136e3
@ -180,10 +180,10 @@ class ThemeField < ActiveRecord::Base
|
|||||||
path = Discourse.store.path_for(upload)
|
path = Discourse.store.path_for(upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
content = File.read(path)
|
|
||||||
error = nil
|
error = nil
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
content = File.read(path)
|
||||||
svg_file = Nokogiri::XML(content) do |config|
|
svg_file = Nokogiri::XML(content) do |config|
|
||||||
config.options = Nokogiri::XML::ParseOptions::NOBLANKS
|
config.options = Nokogiri::XML::ParseOptions::NOBLANKS
|
||||||
end
|
end
|
||||||
|
@ -430,6 +430,11 @@ HTML
|
|||||||
theme_field.destroy!
|
theme_field.destroy!
|
||||||
expect(SvgSprite.custom_svg_sprites(theme.id).size).to eq(0)
|
expect(SvgSprite.custom_svg_sprites(theme.id).size).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'crashes gracefully when svg is invalid' do
|
||||||
|
FileStore::LocalStore.any_instance.stubs(:path_for).returns(nil)
|
||||||
|
expect(theme_field.validate_svg_sprite_xml).to match("Error with icons-sprite")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user