line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "houdini.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define hex2c(c) ((c | 32) % 39 - 9) |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
static int |
10
|
8
|
|
|
|
|
|
unescape(gh_buf *ob, const uint8_t *src, size_t size, bool unescape_plus) |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
size_t i = 0, org; |
13
|
|
|
|
|
|
|
|
14
|
18
|
50
|
|
|
|
|
while (i < size) { |
15
|
|
|
|
|
|
|
org = i; |
16
|
104
|
100
|
|
|
|
|
while (i < size && src[i] != '%' && src[i] != '+') |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
17
|
86
|
|
|
|
|
|
i++; |
18
|
|
|
|
|
|
|
|
19
|
18
|
100
|
|
|
|
|
if (likely(i > org)) { |
20
|
12
|
100
|
|
|
|
|
if (unlikely(org == 0)) { |
21
|
8
|
100
|
|
|
|
|
if (i >= size) |
22
|
|
|
|
|
|
|
return 0; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
gh_buf_grow(ob, HOUDINI_UNESCAPED_SIZE(size)); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
7
|
|
|
|
|
|
gh_buf_put(ob, src + org, i - org); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
/* escaping */ |
31
|
13
|
100
|
|
|
|
|
if (i >= size) |
32
|
|
|
|
|
|
|
break; |
33
|
|
|
|
|
|
|
|
34
|
10
|
50
|
|
|
|
|
if (src[i++] == '+') { |
35
|
0
|
0
|
|
|
|
|
gh_buf_putc(ob, unescape_plus ? ' ' : '+'); |
36
|
0
|
|
|
|
|
|
continue; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
20
|
50
|
|
|
|
|
if (i + 1 < size && _isxdigit(src[i]) && _isxdigit(src[i + 1])) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
40
|
10
|
|
|
|
|
|
unsigned char new_char = (hex2c(src[i]) << 4) + hex2c(src[i + 1]); |
41
|
10
|
|
|
|
|
|
gh_buf_putc(ob, new_char); |
42
|
10
|
|
|
|
|
|
i += 2; |
43
|
|
|
|
|
|
|
} else { |
44
|
10
|
|
|
|
|
|
gh_buf_putc(ob, '%'); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
int |
52
|
4
|
|
|
|
|
|
houdini_unescape_uri(gh_buf *ob, const uint8_t *src, size_t size) |
53
|
|
|
|
|
|
|
{ |
54
|
4
|
|
|
|
|
|
return unescape(ob, src, size, false); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
int |
58
|
0
|
|
|
|
|
|
houdini_unescape_uri_component(gh_buf *ob, const uint8_t *src, size_t size) |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
|
|
|
return unescape(ob, src, size, false); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
int |
64
|
4
|
|
|
|
|
|
houdini_unescape_url(gh_buf *ob, const uint8_t *src, size_t size) |
65
|
|
|
|
|
|
|
{ |
66
|
4
|
|
|
|
|
|
return unescape(ob, src, size, true); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|