Skip to content

Commit 4a80214

Browse files
committed
Relax base64 check, let \n and \r\n
1 parent d136471 commit 4a80214

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/onelogin/ruby-saml/saml_message.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def encode(encoded)
7676
# The function is not strict and does allow newline. This is because some SAML implementations
7777
# uses newline in the base64-encoded data, even if they shouldn't have (RFC4648).
7878
def is_base64?(string)
79-
string.match(%r{\A(([A-Za-z0-9+/]{4})|\n)*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)\Z})
79+
string = string.gsub(/\r\n/, "").gsub(/\n/, "")
80+
string.match(%r{\A(([A-Za-z0-9+/]{4}))*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)\Z})
8081
end
8182

8283
def escape(unescaped)

0 commit comments

Comments
 (0)