| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "ppport.h" |
|
6
|
|
|
|
|
|
|
#include "GenerateFunctions.h" |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#define B_INPLACE 1 |
|
9
|
|
|
|
|
|
|
#define B_LFTOBR 2 |
|
10
|
|
|
|
|
|
|
#define B_SPTONBSP 4 |
|
11
|
|
|
|
|
|
|
#define B_LEAVEKNOWN 8 |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#define B_ESCAPEVAL 1 |
|
14
|
|
|
|
|
|
|
#define B_ADDNEWLINE 2 |
|
15
|
|
|
|
|
|
|
#define B_CLOSETAG 4 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
MODULE = HTML::GenerateUtil PACKAGE = HTML::GenerateUtil |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
SV * |
|
20
|
|
|
|
|
|
|
escape_html(str, ...) |
|
21
|
|
|
|
|
|
|
SV * str |
|
22
|
|
|
|
|
|
|
PREINIT: |
|
23
|
1058
|
|
|
|
|
|
int mode = 0; |
|
24
|
|
|
|
|
|
|
INIT: |
|
25
|
|
|
|
|
|
|
int b_inplace, b_lftobr, b_sptonbsp, b_leaveknown; |
|
26
|
|
|
|
|
|
|
SV * newstr; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
/* Check it's a string */ |
|
29
|
1058
|
|
|
|
|
|
SvGETMAGIC(str); |
|
30
|
1058
|
100
|
|
|
|
|
if (!SvOK(str)) { |
|
31
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
CODE: |
|
34
|
1056
|
100
|
|
|
|
|
if (items > 1) |
|
35
|
1053
|
|
|
|
|
|
mode = (int)SvIV(ST(1)); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
/* Get flags */ |
|
38
|
1056
|
|
|
|
|
|
b_inplace = mode & B_INPLACE; |
|
39
|
1056
|
|
|
|
|
|
b_lftobr = mode & B_LFTOBR; |
|
40
|
1056
|
|
|
|
|
|
b_sptonbsp = mode & B_SPTONBSP; |
|
41
|
1056
|
|
|
|
|
|
b_leaveknown = mode & B_LEAVEKNOWN; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
/* Call helper function */ |
|
44
|
1056
|
|
|
|
|
|
newstr = GF_escape_html(str, b_inplace, b_lftobr, b_sptonbsp, b_leaveknown); |
|
45
|
|
|
|
|
|
|
|
|
46
|
1056
|
50
|
|
|
|
|
if (!newstr) |
|
47
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
/* Increment reference count because RETVAL = does implicit sv_2mortal later */ |
|
50
|
1056
|
100
|
|
|
|
|
if (b_inplace) |
|
51
|
18
|
|
|
|
|
|
SvREFCNT_inc(newstr); |
|
52
|
|
|
|
|
|
|
|
|
53
|
1056
|
|
|
|
|
|
RETVAL = newstr; |
|
54
|
|
|
|
|
|
|
OUTPUT: |
|
55
|
|
|
|
|
|
|
RETVAL |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
SV * |
|
58
|
|
|
|
|
|
|
generate_attributes(attr) |
|
59
|
|
|
|
|
|
|
SV * attr |
|
60
|
|
|
|
|
|
|
INIT: |
|
61
|
|
|
|
|
|
|
SV * attrstr; |
|
62
|
|
|
|
|
|
|
HV * attrhv; |
|
63
|
|
|
|
|
|
|
|
|
64
|
1029
|
50
|
|
|
|
|
if (!SvOK(attr) || !SvROK(attr) || SvTYPE(SvRV(attr)) != SVt_PVHV) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
1029
|
|
|
|
|
|
attrhv = (HV *)SvRV(attr); |
|
69
|
|
|
|
|
|
|
CODE: |
|
70
|
1029
|
|
|
|
|
|
attrstr = GF_generate_attributes(attrhv); |
|
71
|
|
|
|
|
|
|
|
|
72
|
1029
|
|
|
|
|
|
RETVAL = attrstr; |
|
73
|
|
|
|
|
|
|
OUTPUT: |
|
74
|
|
|
|
|
|
|
RETVAL |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
SV * |
|
77
|
|
|
|
|
|
|
generate_tag(tag, attr, val, mode) |
|
78
|
|
|
|
|
|
|
SV * tag |
|
79
|
|
|
|
|
|
|
SV * attr |
|
80
|
|
|
|
|
|
|
SV * val |
|
81
|
|
|
|
|
|
|
int mode |
|
82
|
|
|
|
|
|
|
INIT: |
|
83
|
|
|
|
|
|
|
SV * tagstr; |
|
84
|
1015
|
|
|
|
|
|
HV * attrhv = 0; |
|
85
|
|
|
|
|
|
|
int b_escapeval, b_addnewline, b_closetag; |
|
86
|
|
|
|
|
|
|
|
|
87
|
1015
|
50
|
|
|
|
|
if (!SvOK(tag)) { |
|
88
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
1015
|
100
|
|
|
|
|
if (SvOK(attr) && (!SvROK(attr) || (SvROK(attr) && SvTYPE(SvRV(attr)) != SVt_PVHV))) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
1015
|
100
|
|
|
|
|
if (!SvOK(val)) { |
|
94
|
8
|
|
|
|
|
|
val = 0; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
1015
|
100
|
|
|
|
|
attrhv = SvOK(attr) ? (HV *)SvRV(attr) : 0; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
/* Get flags */ |
|
100
|
1015
|
|
|
|
|
|
b_escapeval = mode & B_ESCAPEVAL; |
|
101
|
1015
|
|
|
|
|
|
b_addnewline = mode & B_ADDNEWLINE; |
|
102
|
1015
|
|
|
|
|
|
b_closetag = mode & B_CLOSETAG; |
|
103
|
|
|
|
|
|
|
CODE: |
|
104
|
1015
|
|
|
|
|
|
tagstr = GF_generate_tag(tag, attrhv, val, b_escapeval, b_addnewline, b_closetag); |
|
105
|
|
|
|
|
|
|
|
|
106
|
1015
|
|
|
|
|
|
RETVAL = tagstr; |
|
107
|
|
|
|
|
|
|
OUTPUT: |
|
108
|
|
|
|
|
|
|
RETVAL |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
SV * |
|
111
|
|
|
|
|
|
|
escape_uri_internal(str, escstr, mode) |
|
112
|
|
|
|
|
|
|
SV * str |
|
113
|
|
|
|
|
|
|
SV * escstr |
|
114
|
|
|
|
|
|
|
int mode |
|
115
|
|
|
|
|
|
|
INIT: |
|
116
|
|
|
|
|
|
|
int b_inplace; |
|
117
|
|
|
|
|
|
|
SV * newstr; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
/* Check it's a string */ |
|
120
|
1284
|
|
|
|
|
|
SvGETMAGIC(str); |
|
121
|
1284
|
100
|
|
|
|
|
if (!SvOK(str) || !SvOK(escstr)) { |
|
|
|
50
|
|
|
|
|
|
|
122
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
/* Get flags */ |
|
126
|
1282
|
|
|
|
|
|
b_inplace = mode & B_INPLACE; |
|
127
|
|
|
|
|
|
|
CODE: |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
/* Call helper function */ |
|
130
|
1282
|
|
|
|
|
|
newstr = GF_escape_uri(str, escstr, b_inplace); |
|
131
|
|
|
|
|
|
|
|
|
132
|
1282
|
50
|
|
|
|
|
if (!newstr) |
|
133
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
/* Increment reference count because RETVAL = does implicit sv_2mortal later */ |
|
136
|
1282
|
100
|
|
|
|
|
if (b_inplace) |
|
137
|
4
|
|
|
|
|
|
SvREFCNT_inc(newstr); |
|
138
|
|
|
|
|
|
|
|
|
139
|
1282
|
|
|
|
|
|
RETVAL = newstr; |
|
140
|
|
|
|
|
|
|
OUTPUT: |
|
141
|
|
|
|
|
|
|
RETVAL |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
void |
|
144
|
|
|
|
|
|
|
set_paranoia(paranoia) |
|
145
|
|
|
|
|
|
|
int paranoia |
|
146
|
|
|
|
|
|
|
CODE: |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
/* Call helper function */ |
|
149
|
0
|
|
|
|
|
|
GF_set_paranoia(paranoia); |
|
150
|
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
152
|
|
|
|
|
|
|
|