]> granicus.if.org Git - ejabberd/commitdiff
Use base64:mime_decode/1 for SASL packets
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 22 Oct 2016 10:09:11 +0000 (13:09 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 22 Oct 2016 10:09:11 +0000 (13:09 +0300)
It will be now possible to accept SASL packets with only
single '=' character set as required by RFC6120

specs/xmpp_codec.spec
src/xmpp_codec.erl

index 81f674bf3fc5b99fca5c2796b64a461a850451da..608e1fe2de6f1e1573e2da210051d6fc4a5129b8 100644 (file)
      #elem{name = <<"auth">>,
            xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
            cdata = #cdata{label = '$text',
-                          dec = {base64, decode, []},
+                          dec = {base64, mime_decode, []},
                           enc = {base64, encode, []}},
            result = {sasl_auth, '$mechanism', '$text'},
            attrs = [#attr{name = <<"mechanism">>,
      #elem{name = <<"challenge">>,
            xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
            cdata = #cdata{label = '$text',
-                          dec = {base64, decode, []},
+                          dec = {base64, mime_decode, []},
                           enc = {base64, encode, []}},
            result = {sasl_challenge, '$text'}}).
 
      #elem{name = <<"response">>,
            xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
            cdata = #cdata{label = '$text',
-                          dec = {base64, decode, []},
+                          dec = {base64, mime_decode, []},
                           enc = {base64, encode, []}},
            result = {sasl_response, '$text'}}).
 
      #elem{name = <<"success">>,
            xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
            cdata = #cdata{label = '$text',
-                          dec = {base64, decode, []},
+                          dec = {base64, mime_decode, []},
                           enc = {base64, encode, []}},
            result = {sasl_success, '$text'}}).
 
@@ -3467,6 +3467,7 @@ enc_ip(Addr) ->
 
 -spec re:split(_, _) -> [binary()].
 -spec base64:decode(_) -> binary().
+-spec base64:mime_decode(_) -> binary().
 
 -spec dec_host_port(_) -> binary() | inet:ip_address() |
                          {binary() | inet:ip_address(), non_neg_integer()}.
index f230dc48917628ad5d4ee825885001d847e24e25..345de7031f81c1dc51457384b236edd071fe95f6 100644 (file)
@@ -29298,7 +29298,7 @@ encode_sasl_success({sasl_success, Text}, __TopXMLNS) ->
 
 decode_sasl_success_cdata(__TopXMLNS, <<>>) -> <<>>;
 decode_sasl_success_cdata(__TopXMLNS, _val) ->
-    case catch base64:decode(_val) of
+    case catch base64:mime_decode(_val) of
       {'EXIT', _} ->
          erlang:error({xmpp_codec,
                        {bad_cdata_value, <<>>, <<"success">>, __TopXMLNS}});
@@ -29338,7 +29338,7 @@ encode_sasl_response({sasl_response, Text},
 
 decode_sasl_response_cdata(__TopXMLNS, <<>>) -> <<>>;
 decode_sasl_response_cdata(__TopXMLNS, _val) ->
-    case catch base64:decode(_val) of
+    case catch base64:mime_decode(_val) of
       {'EXIT', _} ->
          erlang:error({xmpp_codec,
                        {bad_cdata_value, <<>>, <<"response">>, __TopXMLNS}});
@@ -29378,7 +29378,7 @@ encode_sasl_challenge({sasl_challenge, Text},
 
 decode_sasl_challenge_cdata(__TopXMLNS, <<>>) -> <<>>;
 decode_sasl_challenge_cdata(__TopXMLNS, _val) ->
-    case catch base64:decode(_val) of
+    case catch base64:mime_decode(_val) of
       {'EXIT', _} ->
          erlang:error({xmpp_codec,
                        {bad_cdata_value, <<>>, <<"challenge">>, __TopXMLNS}});
@@ -29454,7 +29454,7 @@ encode_sasl_auth_attr_mechanism(_val, _acc) ->
 
 decode_sasl_auth_cdata(__TopXMLNS, <<>>) -> <<>>;
 decode_sasl_auth_cdata(__TopXMLNS, _val) ->
-    case catch base64:decode(_val) of
+    case catch base64:mime_decode(_val) of
       {'EXIT', _} ->
          erlang:error({xmpp_codec,
                        {bad_cdata_value, <<>>, <<"auth">>, __TopXMLNS}});