File Coverage

lib/Escape/Houdini.xs
Criterion Covered Total %
statement 20 20 100.0
branch 42 60 70.0
condition n/a
subroutine n/a
pod n/a
total 62 80 77.5


line stmt bran cond sub pod time code
1             #include "EXTERN.h"
2             #include "perl.h"
3             #include "XSUB.h"
4             #include
5             #include
6              
7             #define WRAPPER(name) \
8             SV *_##name(SV *input){ \
9             gh_buf buffer = GH_BUF_INIT; \
10             SV *result; \
11             STRLEN slen; \
12             char *src_string; \
13             \
14             if( !SvPOK(input) && !SvNOK(input) && !SvIOK(input) ) {\
15             croak( #name "() argument not a string"); \
16             } \
17             \
18             src_string = SvPV(input, slen); \
19             \
20             if( !houdini_##name( &buffer, src_string, slen ) ) { \
21             return newSVsv(input); \
22             } \
23             \
24             result = newSVpvn( buffer.ptr, buffer.size ); \
25             gh_buf_free(&buffer); \
26             SvUTF8_on(result); \
27             \
28             return result; \
29             }
30              
31 15 100         WRAPPER(escape_html)
    100          
    100          
32 13 100         WRAPPER(unescape_html)
    100          
    100          
33 6 50         WRAPPER(escape_xml)
    50          
    50          
34 8 50         WRAPPER(escape_url)
    50          
    50          
35 8 50         WRAPPER(escape_uri)
    50          
    100          
36 8 50         WRAPPER(unescape_url)
    50          
    100          
37 8 50         WRAPPER(unescape_uri)
    50          
    100          
38 8 50         WRAPPER(escape_js)
    50          
    100          
39 8 50         WRAPPER(unescape_js)
    50          
    100          
40 8 50         WRAPPER(escape_href)
    50          
    100          
41              
42             MODULE = Escape::Houdini PACKAGE = Escape::Houdini
43              
44             SV *
45             escape_xml(str)
46             SV *str;
47             CODE:
48 3           RETVAL = _escape_xml(str);
49             OUTPUT:
50             RETVAL
51              
52             SV *
53             escape_html(str)
54             SV *str;
55             CODE:
56 8           RETVAL = _escape_html(str);
57             OUTPUT:
58             RETVAL
59              
60             SV *
61             unescape_html(str)
62             SV *str;
63             CODE:
64 7           RETVAL = _unescape_html(str);
65             OUTPUT:
66             RETVAL
67              
68             SV *
69             escape_uri(str)
70             SV *str;
71             CODE:
72 4           RETVAL = _escape_uri(str);
73             OUTPUT:
74             RETVAL
75              
76             SV *
77             escape_url(str)
78             SV *str;
79             CODE:
80 4           RETVAL = _escape_url(str);
81             OUTPUT:
82             RETVAL
83              
84             SV *
85             escape_href(str)
86             SV *str;
87             CODE:
88 4           RETVAL = _escape_href(str);
89             OUTPUT:
90             RETVAL
91              
92             SV *
93             unescape_uri(str)
94             SV *str;
95             CODE:
96 4           RETVAL = _unescape_uri(str);
97             OUTPUT:
98             RETVAL
99              
100             SV *
101             unescape_url(str)
102             SV *str;
103             CODE:
104 4           RETVAL = _unescape_url(str);
105             OUTPUT:
106             RETVAL
107              
108             SV *
109             escape_js(str)
110             SV *str;
111             CODE:
112 4           RETVAL = _escape_js(str);
113             OUTPUT:
114             RETVAL
115              
116             SV *
117             unescape_js(str)
118             SV *str;
119             CODE:
120 4           RETVAL = _unescape_js(str);
121             OUTPUT:
122             RETVAL