Skip to content

Commit

Permalink
Merge pull request #727 from e-ikuta/remove_chdir
Browse files Browse the repository at this point in the history
Introduce thread safety to SAML schema read
  • Loading branch information
pitbulk authored Jan 10, 2025
2 parents 21b676b + a1f2f7d commit 130b829
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/onelogin/ruby-saml/saml_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ class SamlMessage
PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol".freeze

BASE64_FORMAT = %r(\A([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\Z)
@@mutex = Mutex.new

# @return [Nokogiri::XML::Schema] Gets the schema object of the SAML 2.0 Protocol schema
#
def self.schema
@@mutex.synchronize do
Dir.chdir(File.expand_path("../../../schemas", __FILE__)) do
::Nokogiri::XML::Schema(File.read("saml-schema-protocol-2.0.xsd"))
end
path = File.expand_path("../../../schemas/saml-schema-protocol-2.0.xsd", __FILE__)
File.open(path) do |file|
::Nokogiri::XML::Schema(file)
end
end

Expand Down

0 comments on commit 130b829

Please sign in to comment.