line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "houdini.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
int |
8
|
4
|
|
|
|
|
|
houdini_unescape_js(gh_buf *ob, const uint8_t *src, size_t size) |
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
size_t i = 0, org, ch; |
11
|
|
|
|
|
|
|
|
12
|
6
|
50
|
|
|
|
|
while (i < size) { |
13
|
|
|
|
|
|
|
org = i; |
14
|
41
|
100
|
|
|
|
|
while (i < size && src[i] != '\\') |
|
|
100
|
|
|
|
|
|
15
|
35
|
|
|
|
|
|
i++; |
16
|
|
|
|
|
|
|
|
17
|
6
|
50
|
|
|
|
|
if (likely(i > org)) { |
18
|
6
|
100
|
|
|
|
|
if (unlikely(org == 0)) { |
19
|
4
|
100
|
|
|
|
|
if (i >= size) |
20
|
|
|
|
|
|
|
return 0; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
gh_buf_grow(ob, HOUDINI_UNESCAPED_SIZE(size)); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
|
gh_buf_put(ob, src + org, i - org); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
/* escaping */ |
29
|
4
|
100
|
|
|
|
|
if (i == size) |
30
|
|
|
|
|
|
|
break; |
31
|
|
|
|
|
|
|
|
32
|
2
|
50
|
|
|
|
|
if (++i == size) { |
33
|
0
|
|
|
|
|
|
gh_buf_putc(ob, '\\'); |
34
|
0
|
|
|
|
|
|
break; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
|
ch = src[i]; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
|
switch (ch) { |
40
|
|
|
|
|
|
|
case 'n': |
41
|
|
|
|
|
|
|
ch = '\n'; |
42
|
|
|
|
|
|
|
/* pass through */ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
case '\\': |
45
|
|
|
|
|
|
|
case '\'': |
46
|
|
|
|
|
|
|
case '\"': |
47
|
|
|
|
|
|
|
case '/': |
48
|
2
|
|
|
|
|
|
gh_buf_putc(ob, ch); |
49
|
2
|
|
|
|
|
|
i++; |
50
|
2
|
|
|
|
|
|
break; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
default: |
53
|
0
|
|
|
|
|
|
gh_buf_putc(ob, '\\'); |
54
|
2
|
|
|
|
|
|
break; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|