solidus_core 3.1.0 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6d8a64c0ba51b637a6a5eb82952d5920f388413f74d271920c41b6c34b00b5f
4
- data.tar.gz: a92bbdc37bd0a9f9a53fe943542ba0f4890af67290faf937de4a57583cdb1ffa
3
+ metadata.gz: cabe9b97feb5c88754e6be9c0cb22e63977a3972805c725f88861bfa2c3d8beb
4
+ data.tar.gz: 3c44f84249aa9dba36fa4afba31ae40943cf80b4484d8adf979c946374b25904
5
5
  SHA512:
6
- metadata.gz: 0dd269d1a10a861a6d76cba306cf3b42b758773d4fe4e3265986e0abfe318e40ba2468d6431ec89d472b72591a23e19684a20afa37bb48f0be71371e79736e0f
7
- data.tar.gz: c524310230c534ebc135368fbf5d1b75def4f3b3672f8b4818b85d6e40d2fd04f1bfb03e37d0218f37d5b5bb7167499c2deff8bbd2593a8571f9b1de211d665c
6
+ metadata.gz: b488346a08197d39759e4781fdfe087daeb362b76a6f4dd4262c730e7eda328c55a427f7a503c2c301e286814b82106dff5339602e927fc38bf7152f40c1be2c
7
+ data.tar.gz: 2156b59d9f751645dfcb80a5905d990d2e65945ee60733181eda7e3ba49b2a4a4628517c00c4179560e2ec06af73842047fd8aa1b65d8f99bb4f04ada1c871a3
@@ -67,6 +67,14 @@ module Spree
67
67
  config.after_initialize do
68
68
  Spree::Config.check_load_defaults_called('Spree::Config')
69
69
  end
70
+
71
+ config.after_initialize do
72
+ if defined?(Spree::Auth::Engine) &&
73
+ Gem::Version.new(Spree::Auth::VERSION) < Gem::Version.new('2.5.4') &&
74
+ defined?(Spree::UsersController)
75
+ Spree::UsersController.protect_from_forgery with: :exception
76
+ end
77
+ end
70
78
  end
71
79
  end
72
80
  end
@@ -12,7 +12,7 @@ module Spree
12
12
  # end
13
13
  #
14
14
  class EmailValidator < ActiveModel::EachValidator
15
- EMAIL_REGEXP = /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/
15
+ EMAIL_REGEXP = URI::MailTo::EMAIL_REGEXP
16
16
 
17
17
  def validate_each(record, attribute, value)
18
18
  unless EMAIL_REGEXP.match? value
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "3.1.0"
4
+ VERSION = "3.1.4"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
data/lib/spree/core.rb CHANGED
@@ -62,13 +62,24 @@ module Spree
62
62
  end
63
63
 
64
64
  module Core
65
- def self.has_install_generator_been_run?
66
- (Rails.env.test? && Rails.application.class.name == 'DummyApp::Application') ||
67
- Rails.application.paths['config/initializers'].paths.any? do |path|
68
- File.exist?(path.join('spree.rb'))
69
- end
65
+ # @api private
66
+ def self.has_install_generator_been_run?(rails_paths: Rails.application.paths, initializer_name: 'spree.rb', dummy_app_name: 'DummyApp::Application')
67
+ does_spree_initializer_exist?(rails_paths, initializer_name) ||
68
+ running_solidus_test_suite_with_dummy_app?(dummy_app_name)
70
69
  end
71
70
 
71
+ def self.running_solidus_test_suite_with_dummy_app?(dummy_app_name)
72
+ Rails.env.test? && Rails.application.class.name == dummy_app_name
73
+ end
74
+ private_class_method :running_solidus_test_suite_with_dummy_app?
75
+
76
+ def self.does_spree_initializer_exist?(rails_paths, initializer_name)
77
+ rails_paths['config/initializers'].any? do |path|
78
+ File.exist?(Pathname.new(path).join(initializer_name))
79
+ end
80
+ end
81
+ private_class_method :does_spree_initializer_exist?
82
+
72
83
  class GatewayError < RuntimeError; end
73
84
  end
74
85
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/deprecation'
3
4
  require 'spree/encryptor'
4
5
 
5
6
  module Spree::Preferences
@@ -26,8 +27,38 @@ module Spree::Preferences
26
27
  options[:default] = preference_encryptor.encrypt(options[:default])
27
28
  end
28
29
 
29
- default = options[:default]
30
- default = proc { options[:default] } unless default.is_a?(Proc)
30
+ default = begin
31
+ given = options[:default]
32
+ if ancestors.include?(Spree::Preferences::Configuration) &&
33
+ given.is_a?(Proc) &&
34
+ given.lambda? &&
35
+ given.arity.zero?
36
+ Spree::Deprecation.warn <<~MSG
37
+ The arity of a proc given as the default for a preference
38
+ has changed from 0 to 1 on Solidus 3.1. The Solidus
39
+ version for the loaded preference defaults is given as the
40
+ proc's argument from this point on.
41
+
42
+ If you don't need to return a different default value
43
+ depending on the loaded Solidus version, you can change
44
+ the proc so that it doesn't have lambda semantics (lambdas
45
+ raise when extra arguments are supplied, while raw procs
46
+ don't). E.g.:
47
+
48
+ preference :foo, :string, default: proc { true }
49
+
50
+ If you want to branch on the provided Solidus version, you can do like the following:
51
+
52
+ preference :foo, :string, default: by_version(true, "3.2.0" => false)
53
+
54
+ MSG
55
+ ->(_default_context) { given.call }
56
+ elsif given.is_a?(Proc)
57
+ given
58
+ else
59
+ proc { given }
60
+ end
61
+ end
31
62
 
32
63
  # The defined preferences on a class are all those defined directly on
33
64
  # that class as well as those defined on ancestors.
@@ -5,7 +5,7 @@ module Spree
5
5
  module BlacklistUrls
6
6
  def setup_url_blacklist(browser)
7
7
  if browser.respond_to?(:url_blacklist)
8
- browser.url_blacklist = ['http://fonts.googleapis.com']
8
+ browser.url_blacklist = ['https://fonts.googleapis.com']
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :solidus do
4
+ desc 'Prints orders with invalid email (after fix for GHSA-qxmr-qxh6-2cc9)'
5
+ task check_orders_with_invalid_email: :environment do
6
+ matches = Spree::Order.find_each.reduce([]) do |matches, order|
7
+ order.email.nil? || Spree::EmailValidator::EMAIL_REGEXP.match?(order.email) ? matches : matches + [order]
8
+ end
9
+ if matches.any?
10
+ puts 'Email / ID / Number'
11
+ puts(matches.map do |order|
12
+ "#{order.email} / #{order.id} / #{order.number}"
13
+ end.join("\n"))
14
+ else
15
+ puts 'NO MATCHES'
16
+ end
17
+ end
18
+ end
data/solidus_core.gemspec CHANGED
@@ -55,7 +55,12 @@ $ bin/rails g solidus:install
55
55
  If you are updating Solidus from an older version, please run
56
56
  the following commands to complete the update:
57
57
 
58
- $ bin/rails solidus:upgrade
58
+ $ bin/rails g solidus:update
59
+
60
+ Please, don't forget to look at the CHANGELOG to see what has changed and
61
+ whether you need to perform other tasks.
62
+
63
+ https://github.com/solidusio/solidus/blob/master/CHANGELOG.md
59
64
 
60
65
  Please report any issues at:
61
66
  - https://github.com/solidusio/solidus/issues
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -907,6 +907,7 @@ files:
907
907
  - lib/spree/testing_support/url_helpers.rb
908
908
  - lib/spree/user_class_handle.rb
909
909
  - lib/spree_core.rb
910
+ - lib/tasks/solidus/check_orders_with_invalid_email.rake
910
911
  - lib/tasks/solidus/delete_prices_with_nil_amount.rake
911
912
  - solidus_core.gemspec
912
913
  - vendor/assets/javascripts/jquery.payment.js
@@ -928,7 +929,12 @@ post_install_message: |
928
929
  If you are updating Solidus from an older version, please run
929
930
  the following commands to complete the update:
930
931
 
931
- $ bin/rails solidus:upgrade
932
+ $ bin/rails g solidus:update
933
+
934
+ Please, don't forget to look at the CHANGELOG to see what has changed and
935
+ whether you need to perform other tasks.
936
+
937
+ https://github.com/solidusio/solidus/blob/master/CHANGELOG.md
932
938
 
933
939
  Please report any issues at:
934
940
  - https://github.com/solidusio/solidus/issues
@@ -948,8 +954,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
948
954
  - !ruby/object:Gem::Version
949
955
  version: 1.8.23
950
956
  requirements: []
951
- rubygems_version: 3.2.20
952
- signing_key:
957
+ rubygems_version: 3.1.2
958
+ signing_key:
953
959
  specification_version: 4
954
960
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
955
961
  test_files: []