File tree Expand file tree Collapse file tree 3 files changed +6
-1
lines changed Expand file tree Collapse file tree 3 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class Utils
22
22
#
23
23
def self . format_cert ( cert )
24
24
# don't try to format an encoded certificate or if is empty or nil
25
- return cert if cert . nil? || cert . empty? || cert . match ( / \x0d / )
25
+ return cert if cert . nil? || cert . empty? || ! cert . ascii_only?
26
26
27
27
if cert . scan ( /BEGIN CERTIFICATE/ ) . length > 1
28
28
formatted_cert = [ ]
Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ class UtilsTest < Minitest::Test
29
29
assert_equal formatted_certificate , OneLogin ::RubySaml ::Utils . format_cert ( invalid_certificate2 )
30
30
end
31
31
32
+ it "returns the cert when it's encoded" do
33
+ encoded_certificate = read_certificate ( "certificate.der" )
34
+ assert_equal encoded_certificate , OneLogin ::RubySaml ::Utils . format_cert ( encoded_certificate )
35
+ end
36
+
32
37
it "reformats the certificate when there line breaks and no headers" do
33
38
invalid_certificate3 = read_certificate ( "invalid_certificate3" )
34
39
assert_equal formatted_certificate , OneLogin ::RubySaml ::Utils . format_cert ( invalid_certificate3 )
You can’t perform that action at this time.
0 commit comments