Skip to content

Commit 91a7d27

Browse files
committed
Migrated to double-quoted XML
1 parent 0c8efe1 commit 91a7d27

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

UPGRADING.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ codebase for `RubySaml::XML::` and replace it as appropriate. In addition, you m
3737
`require 'xml_security'` with `require 'ruby_saml/xml'`.
3838

3939
For backward compatibility, the alias `XMLSecurity = RubySaml::XML` has been set, so `RubySaml::XML::` will still work
40-
as before. In addition, a shim file has been added so that `require 'xml_security'` continues to work.
40+
as before, unless you have defined `XMLSecurity` prior to loading RubySaml.
41+
In addition, a shim file has been added so that `require 'xml_security'` continues to work.
4142
These aliases will be removed in RubySaml version `2.1.0`.
4243

4344
### Security: Change default hashing algorithm to SHA-256 (was SHA-1)
@@ -59,6 +60,23 @@ settings.security[:digest_method] = RubySaml::XML::Crypto::SHA1
5960
settings.security[:signature_method] = RubySaml::XML::Crypto::RSA_SHA1
6061
```
6162

63+
### Behavior change of double_quote_xml_attribute_values setting
64+
65+
`settings.double_quote_xml_attribute_values` now always behaves as if it is set to `true`,
66+
i.e. RubySaml now always uses double quotes for attribute values when generating XML.
67+
68+
The reasons for this change are:
69+
- RubySaml will use Nokogiri instead of REXML to generate XML. Nokogiri does not support
70+
generating XML with single quotes.
71+
- Double quotes in XML tends to be the standard; there are no known SAML clients in the wild
72+
which cannot support double-quoted XML.
73+
74+
If you require to use single quotes in your XML output, you may try the following Regexp:
75+
76+
```ruby
77+
78+
```
79+
6280
### Removal of embed_sign setting
6381

6482
The deprecated `settings.security[:embed_sign]` parameter has been removed. If you were using it, please instead switch

lib/ruby_saml/authrequest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def create_params(settings, params={})
5454
end
5555

5656
request_doc = create_authentication_xml_doc(settings)
57-
request_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values
57+
request_doc.context[:attribute_quote] = :quote
5858

5959
request = +""
6060
request_doc.write(request)

lib/ruby_saml/logoutrequest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create_params(settings, params={})
5252
end
5353

5454
request_doc = create_logout_request_xml_doc(settings)
55-
request_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values
55+
request_doc.context[:attribute_quote] = :quote
5656

5757
request = +""
5858
request_doc.write(request)

lib/ruby_saml/settings.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def initialize(overrides = {}, keep_security_attributes = false)
5454
attr_accessor :name_identifier_value
5555
attr_accessor :name_identifier_value_requested
5656
attr_accessor :sessionindex
57-
attr_accessor :double_quote_xml_attribute_values
5857
attr_accessor :message_max_bytesize
5958
attr_accessor :passive
6059
attr_reader :protocol_binding
@@ -230,7 +229,6 @@ def get_binding(value)
230229
idp_cert_fingerprint_algorithm: RubySaml::XML::Crypto::SHA256,
231230
message_max_bytesize: 250_000,
232231
soft: true,
233-
double_quote_xml_attribute_values: false,
234232
security: {
235233
authn_requests_signed: false,
236234
logout_requests_signed: false,
@@ -248,6 +246,20 @@ def get_binding(value)
248246
}.freeze
249247
}.freeze
250248

249+
{
250+
double_quote_xml_attribute_values: true
251+
}.each do |old_param, new_value|
252+
# @deprecated Will be removed in v2.1.0
253+
define_method(old_param) do
254+
removed_deprecation(old_param, new_value)
255+
end
256+
257+
# @deprecated Will be removed in v2.1.0
258+
define_method(:"#{old_param}=") do |_|
259+
removed_deprecation(old_param, new_value)
260+
end
261+
end
262+
251263
{
252264
issuer: :sp_entity_id,
253265
idp_sso_target_url: :idp_sso_service_url,
@@ -355,6 +367,12 @@ def compress_response=(value)
355367

356368
private
357369

370+
# @deprecated Will be removed in v2.1.0
371+
def removed_deprecation(old_param, new_value)
372+
Logging.deprecate "`RubySaml::Settings##{old_param}` is deprecated and will be removed in RubySaml 2.1.0. " \
373+
"It no longer has any effect, and will behave as if always set to #{new_value.inspect}."
374+
end
375+
358376
# @deprecated Will be removed in v2.1.0
359377
def replaced_deprecation(old_param, new_param)
360378
Logging.deprecate "`RubySaml::Settings##{old_param}` is deprecated and will be removed in RubySaml 2.1.0. " \

lib/ruby_saml/slo_logoutresponse.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def create_params(settings, request_id = nil, logout_message = nil, params = {},
6060
end
6161

6262
response_doc = create_logout_response_xml_doc(settings, request_id, logout_message, logout_status_code)
63-
response_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values
63+
response_doc.context[:attribute_quote] = :quote
6464

6565
response = +""
6666
response_doc.write(response)

0 commit comments

Comments
 (0)