Skip to content

Commit 4a80d41

Browse files
committed
Port malformed doc commit
1 parent 24c3934 commit 4a80d41

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

lib/ruby_saml/logoutresponse.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def validate_success_status
151151
# @raise [ValidationError] if soft == false and validation fails
152152
#
153153
def validate_structure
154-
unless valid_saml?(document, soft)
154+
check_malformed_doc = check_malformed_doc?(settings)
155+
unless valid_saml?(document, soft, check_malformed_doc: check_malformed_doc)
155156
return append_error("Invalid SAML Logout Response. Not match the saml-schema-protocol-2.0.xsd")
156157
end
157158

lib/ruby_saml/response.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,12 @@ def validate_success_status
450450
def validate_structure
451451
structure_error_msg = "Invalid SAML Response. Not match the saml-schema-protocol-2.0.xsd"
452452

453-
unless valid_saml?(document, soft, check_malformed_doc: check_malformed_doc_enabled?)
453+
check_malformed_doc = check_malformed_doc_enabled?
454+
unless valid_saml?(document, soft, check_malformed_doc: check_malformed_doc)
454455
return append_error(structure_error_msg)
455456
end
456457

457-
if decrypted_document && !valid_saml?(decrypted_document, soft, check_malformed_doc: check_malformed_doc_enabled?)
458+
if decrypted_document && !valid_saml?(decrypted_document, soft, check_malformed_doc: check_malformed_doc)
458459
return append_error(structure_error_msg)
459460
end
460461

@@ -1106,9 +1107,7 @@ def parse_time(node, attribute)
11061107
end
11071108

11081109
def check_malformed_doc_enabled?
1109-
default_value = RubySaml::Settings::DEFAULTS[:check_malformed_doc]
1110-
1111-
settings.nil? ? default_value : settings.check_malformed_doc
1110+
check_malformed_doc?(settings)
11121111
end
11131112
end
11141113
end

lib/ruby_saml/saml_message.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,11 @@ def inflate(deflated)
167167
def deflate(inflated)
168168
Zlib::Deflate.deflate(inflated, Zlib::BEST_COMPRESSION)[2..-5]
169169
end
170+
171+
def check_malformed_doc?(settings)
172+
default_value = RubySaml::Settings::DEFAULTS[:check_malformed_doc]
173+
174+
settings.nil? ? default_value : settings.check_malformed_doc
175+
end
170176
end
171177
end

lib/ruby_saml/slo_logoutrequest.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def validate_not_on_or_after
233233
# @raise [ValidationError] if soft == false and validation fails
234234
#
235235
def validate_structure
236-
unless valid_saml?(document, soft)
236+
check_malformed_doc = check_malformed_doc?(settings)
237+
unless valid_saml?(document, soft, check_malformed_doc: check_malformed_doc)
237238
return append_error("Invalid SAML Logout Request. Not match the saml-schema-protocol-2.0.xsd")
238239
end
239240

0 commit comments

Comments
 (0)