0
|
1 /* BMP - Cross-platform multimedia player
|
|
2 * Copyright (C) 2003-2004 BMP development team.
|
|
3 *
|
|
4 * Based on XMMS:
|
|
5 * Copyright (C) 1998-2003 XMMS development team.
|
|
6 *
|
|
7 * This program is free software; you can redistribute it and/or modify
|
1460
|
8 * it under the terms of the GNU General Public License as published by
|
0
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
1459
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
0
|
20 */
|
|
21
|
|
22 #include "urldecode.h"
|
|
23
|
|
24 #include <glib.h>
|
|
25 #include <stdio.h>
|
|
26 #include <string.h>
|
|
27
|
|
28 #include "util.h"
|
|
29
|
|
30 gchar *
|
|
31 xmms_urldecode_plain(const gchar * encoded_path)
|
|
32 {
|
|
33 const gchar *cur, *ext;
|
|
34 gchar *path, *tmp;
|
|
35 gint realchar;
|
|
36
|
|
37 if (!encoded_path)
|
|
38 return NULL;
|
|
39
|
|
40 cur = encoded_path;
|
|
41 if (*cur == '/')
|
|
42 while (cur[1] == '/')
|
|
43 cur++;
|
|
44
|
|
45 tmp = g_malloc0(strlen(cur) + 1);
|
|
46
|
|
47 while ((ext = strchr(cur, '%')) != NULL) {
|
|
48 strncat(tmp, cur, ext - cur);
|
|
49 ext++;
|
|
50 cur = ext + 2;
|
|
51 if (!sscanf(ext, "%2x", &realchar)) {
|
|
52 /*
|
|
53 * Assume it is a literal '%'. Several file
|
|
54 * managers send unencoded file: urls on on
|
|
55 * drag and drop.
|
|
56 */
|
|
57 realchar = '%';
|
|
58 cur -= 2;
|
|
59 }
|
|
60 tmp[strlen(tmp)] = realchar;
|
|
61 }
|
|
62
|
|
63 path = g_strconcat(tmp, cur, NULL);
|
|
64 g_free(tmp);
|
|
65 return path;
|
|
66 }
|