2
* Simple URL decoding function
3
* Copyright (c) 2012 Antti Seppälä
6
* RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
7
* T. Berners-Lee et al. The Internet Society, 2005
9
* based on http://www.icosaedro.it/apache/urldecode.c
10
* from Umberto Salsi (salsi@icosaedro.it)
12
* This file is part of FFmpeg.
14
* FFmpeg is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU Lesser General Public
16
* License as published by the Free Software Foundation; either
17
* version 2.1 of the License, or (at your option) any later version.
19
* FFmpeg is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
* Lesser General Public License for more details.
24
* You should have received a copy of the GNU Lesser General Public
25
* License along with FFmpeg; if not, write to the Free Software
26
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31
#include "libavutil/mem.h"
32
#include "libavutil/avstring.h"
33
#include "urldecode.h"
35
char *ff_urldecode(const char *url)
37
int s = 0, d = 0, url_len = 0;
44
url_len = strlen(url) + 1;
45
dest = av_malloc(url_len);
53
if (c == '%' && s + 2 < url_len) {
56
if (av_isxdigit(c2) && av_isxdigit(c3)) {
70
dest[d++] = 16 * c2 + c3;
72
} else { /* %zz or something other invalid */
77
} else if (c == '+') {