if (state->auth_type == HTTP_AUTH_BASIC) {
int auth_b64_len, len;
- char *ptr, *decoded_auth = ff_urldecode(auth);
+ char *ptr, *decoded_auth = ff_urldecode(auth, 1);
if (!decoded_auth)
return NULL;
av_strlcat(ptr, "\r\n", len - (ptr - authstr));
av_free(decoded_auth);
} else if (state->auth_type == HTTP_AUTH_DIGEST) {
- char *username = ff_urldecode(auth), *password;
+ char *username = ff_urldecode(auth, 1), *password;
if (!username)
return NULL;
#include "libavutil/avstring.h"
#include "urldecode.h"
-char *ff_urldecode(const char *url)
+char *ff_urldecode(const char *url, int decode_plus_sign)
{
int s = 0, d = 0, url_len = 0;
char c;
dest[d++] = c2;
dest[d++] = c3;
}
- } else if (c == '+') {
+ } else if (c == '+' && decode_plus_sign) {
dest[d++] = ' ';
} else {
dest[d++] = c;
* in that case the original string is duplicated.
*
* @param url a string to be decoded.
+ * @param decode_plus_sign if nonzero plus sign is decoded to space
* @return new string with the URL decoded or NULL if decoding failed.
* Note that the returned string should be explicitly freed when not
* used anymore.
*/
-char *ff_urldecode(const char *url);
+char *ff_urldecode(const char *url, int decode_plus_sign);
#endif /* AVFORMAT_URLDECODE_H */