| 1 |
|
| MODULE = Punk PACKAGE = Punk::Plugin::Sitemap |
| 2 |
|
| |
| 3 |
|
| PROTOTYPES: DISABLE |
| 4 |
|
| |
| 5 |
|
| SV * |
| 6 |
|
| new(class) |
| 7 |
|
| SV *class |
| 8 |
|
| CODE: |
| 9 |
43 |
| RETVAL = sv_bless(newRV_noinc(newSViv(0)), |
| 10 |
|
| gv_stashpv(SvPV_nolen(class), GV_ADD)); |
| 11 |
|
| OUTPUT: |
| 12 |
|
| RETVAL |
| 13 |
|
| |
| 14 |
|
| # use Punk::Plugin::Sitemap; |
| 15 |
|
| # |
| 16 |
|
| # Installs the `sitemap` keyword at COMPILE time, which is the only moment |
| 17 |
|
| # that makes the bareword form parse: |
| 18 |
|
| # |
| 19 |
|
| # sitemap users => sub { ... }; |
| 20 |
|
| # |
| 21 |
|
| # `plugin 'Sitemap'` runs at RUNTIME of the package body, long after the |
| 22 |
|
| # statement above has been compiled, so a keyword installed only there is one |
| 23 |
|
| # perl has already refused to parse. Punk::Plugin::Queue and ::OpenTelemetry |
| 24 |
|
| # split it the same way and for the same reason. |
| 25 |
|
| # |
| 26 |
|
| # Without the `use`, the parenthesised form still works, because perl resolves |
| 27 |
|
| # a call with parentheses at runtime: |
| 28 |
|
| # |
| 29 |
|
| # sitemap('users' => sub { ... }); |
| 30 |
|
| void |
| 31 |
|
| import(class, ...) |
| 32 |
|
| SV *class |
| 33 |
|
| CODE: |
| 34 |
|
| { |
| 35 |
20 |
▶ | const char *pkg = CopSTASHPV(PL_curcop); |
Branch: 7 branches
| Branch | True | False | Total |
| const char *pkg = CopSTASHPV(PL_curcop); |
20 |
0 |
20 |
| const char *pkg = CopSTASHPV(PL_curcop); |
20 |
0 |
20 |
| const char *pkg = CopSTASHPV(PL_curcop); |
20 |
0 |
20 |
| const char *pkg = CopSTASHPV(PL_curcop); |
0 |
20 |
20 |
| const char *pkg = CopSTASHPV(PL_curcop); |
0 |
0 |
0 |
| const char *pkg = CopSTASHPV(PL_curcop); |
20 |
0 |
20 |
| const char *pkg = CopSTASHPV(PL_curcop); |
0 |
20 |
20 |
|
| 36 |
|
| SV *pkgsv, *appsv; |
| 37 |
|
| PERL_UNUSED_VAR(class); |
| 38 |
20 |
▶ | # uncoverable branch true |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable branch true |
0 |
20 |
20 |
|
| 39 |
20 |
| # uncoverable condition left count:1 class:ignore_covered_err |
| 40 |
|
| if (!pkg) XSRETURN_EMPTY; |
| 41 |
|
| pkgsv = sv_2mortal(newSVpv(pkg, 0)); |
| 42 |
|
| /* Not a Punk application: nothing to install a keyword on, and that |
| 43 |
|
| * is legitimate - a test or a script may load this for its class |
| 44 |
|
| * methods alone. Silence rather than a croak, because the failure |
| 45 |
20 |
▶ | * mode for getting the order wrong (`use Punk` second) is perl |
Branch: 1 branch
| Branch | True | False | Total |
| * mode for getting the order wrong (`use Punk` second) is perl |
5 |
15 |
20 |
|
| 46 |
15 |
| * refusing to compile the `sitemap` line, which says so itself. */ |
| 47 |
15 |
▶ | if (!pkc_can_meth(aTHX_ pkgsv, "punk_app")) XSRETURN_EMPTY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pkc_can_meth(aTHX_ pkgsv, "punk_app")) XSRETURN_EMPTY; |
15 |
0 |
15 |
|
| 48 |
15 |
| appsv = pcx_call_meth(aTHX_ pkgsv, "punk_app", NULL, 0, 1); |
| 49 |
|
| # uncoverable branch false |
| 50 |
|
| # uncoverable condition right count:1 class:ignore_covered_err |
| 51 |
|
| if (appsv) { |
| 52 |
|
| pks_install_kw(aTHX_ sv_2mortal(appsv)); |
| 53 |
|
| } |
| 54 |
|
| } |
| 55 |
|
| |
| 56 |
|
| # register($app, \%opts) |
| 57 |
|
| # |
| 58 |
|
| # `base` is configuration, with no fallback to the request's Host, ever. The |
| 59 |
|
| # sitemap protocol wants absolute URLs, and taking the host from the request |
| 60 |
|
| # means an attacker sending `Host: evil.example` gets a sitemap naming their |
| 61 |
|
| # host for every page on the site - delivered to search engines, and invisible |
| 62 |
|
| # to the owner, whose own request produces a correct file. |
| 63 |
|
| # |
| 64 |
|
| # When no `base` is passed it defaults to the application's `host` - which is |
| 65 |
|
| # still configuration, declared once at the app level. The check happens at |
| 66 |
|
| # to_app (pks_resolve_base) rather than here, because `host` may legitimately |
| 67 |
|
| # be declared on either side of the `plugin` line. |
| 68 |
|
| void |
| 69 |
|
| register(self, app, opts = &PL_sv_undef) |
| 70 |
|
| SV *self |
| 71 |
|
| SV *app |
| 72 |
|
| SV *opts |
| 73 |
|
| CODE: |
| 74 |
|
| { |
| 75 |
43 |
| HV *h = app_hv(aTHX_ app); |
| 76 |
43 |
| SV **b = NULL; |
| 77 |
|
| PERL_UNUSED_VAR(self); |
| 78 |
43 |
▶ | # uncoverable branch false |
Branch: 2 branches
| Branch | True | False | Total |
| # uncoverable branch false |
43 |
0 |
43 |
| # uncoverable branch false |
43 |
0 |
43 |
|
| 79 |
43 |
| # uncoverable condition right count:1 class:ignore_covered_err |
| 80 |
43 |
▶ | # uncoverable condition right count:2 class:ignore_covered_err |
Branch: 4 branches
| Branch | True | False | Total |
| # uncoverable condition right count:2 class:ignore_covered_err |
36 |
7 |
43 |
| # uncoverable condition right count:2 class:ignore_covered_err |
36 |
0 |
36 |
| # uncoverable condition right count:2 class:ignore_covered_err |
36 |
0 |
36 |
| # uncoverable condition right count:2 class:ignore_covered_err |
36 |
0 |
36 |
|
| 81 |
36 |
| if (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
| 82 |
|
| b = hv_fetchs((HV *)SvRV(opts), "base", 0); |
| 83 |
|
| # uncoverable condition right count:2 class:ignore_covered_err |
| 84 |
43 |
| # uncoverable condition right count:3 class:ignore_covered_err |
| 85 |
43 |
| # uncoverable condition right count:4 class:ignore_covered_err |
| 86 |
43 |
| if (b && *b && SvOK(*b) && SvCUR(*b)) |
| 87 |
43 |
| (void)hv_stores(h, "sitemap_base", newSVsv(*b)); |
| 88 |
43 |
| { /* the routes this plugin adds for itself: out of the sitemap, |
| 89 |
|
| * and out of robots.txt's Disallow list too */ |
| 90 |
|
| AV *own = newAV(); |
| 91 |
|
| av_push(own, newSVpvs("/sitemap.xml")); |
| 92 |
|
| av_push(own, newSVpvs("/sitemap/:n")); |
| 93 |
|
| av_push(own, newSVpvs("/robots.txt")); |
| 94 |
|
| (void)hv_stores(h, "sitemap_own", newRV_noinc((SV *)own)); |
| 95 |
|
| } |
| 96 |
|
| |
| 97 |
|
| /* Both documents are served from the site ROOT regardless of any |
| 98 |
|
| * mount prefix: /sitemap.xml is a fixed location and a crawler will |
| 99 |
|
| * not look anywhere else. */ |
| 100 |
|
| { |
| 101 |
43 |
| SV *argv[5]; |
| 102 |
43 |
| AV *cap; |
| 103 |
43 |
| SV *r; |
| 104 |
43 |
| |
| 105 |
43 |
| /* /sitemap.xml - the index, or the single part. Opts itself out, |
| 106 |
43 |
| * because a sitemap listing itself is noise a crawler follows. */ |
| 107 |
43 |
| cap = newAV(); |
| 108 |
|
| av_push(cap, newSVsv(app)); |
| 109 |
43 |
| av_push(cap, newSViv(0)); |
| 110 |
43 |
| argv[0] = sv_2mortal(newSVpvs("GET")); |
| 111 |
43 |
| argv[1] = sv_2mortal(newSVpvs("/sitemap.xml")); |
| 112 |
|
| argv[2] = sv_2mortal(punk_closure(aTHX_ pks_serve_cb, cap)); |
| 113 |
43 |
| argv[3] = &PL_sv_undef; |
| 114 |
43 |
▶ | { |
Branch: 1 branch
| Branch | True | False | Total |
| { |
43 |
0 |
43 |
|
| 115 |
|
| HV *o = newHV(); |
| 116 |
|
| (void)hv_stores(o, K_SITEMAP, newSViv(0)); |
| 117 |
|
| argv[4] = sv_2mortal(newRV_noinc((SV *)o)); |
| 118 |
43 |
| } |
| 119 |
43 |
| r = pcx_call_meth(aTHX_ app, "route", argv, 5, 1); |
| 120 |
43 |
| # uncoverable branch false |
| 121 |
43 |
| # uncoverable condition right count:1 class:ignore_covered_err |
| 122 |
43 |
| if (r) SvREFCNT_dec(r); |
| 123 |
43 |
| |
| 124 |
43 |
| /* /sitemap/1.xml, /2.xml and so on. A capture, so the listing |
| 125 |
43 |
| * rules keep it out of the sitemap with no option needed. */ |
| 126 |
43 |
| cap = newAV(); |
| 127 |
43 |
▶ | av_push(cap, newSVsv(app)); |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(cap, newSVsv(app)); |
43 |
0 |
43 |
|
| 128 |
|
| av_push(cap, newSViv(1)); |
| 129 |
|
| argv[0] = sv_2mortal(newSVpvs("GET")); |
| 130 |
|
| argv[1] = sv_2mortal(newSVpvs("/sitemap/:n")); |
| 131 |
|
| argv[2] = sv_2mortal(punk_closure(aTHX_ pks_serve_cb, cap)); |
| 132 |
43 |
| argv[3] = &PL_sv_undef; |
| 133 |
43 |
| argv[4] = &PL_sv_undef; |
| 134 |
43 |
| r = pcx_call_meth(aTHX_ app, "route", argv, 5, 1); |
| 135 |
43 |
| # uncoverable branch false |
| 136 |
43 |
| # uncoverable condition right count:1 class:ignore_covered_err |
| 137 |
43 |
| if (r) SvREFCNT_dec(r); |
| 138 |
|
| |
| 139 |
43 |
| /* /robots.txt, from the same exclusion list. Opts itself out |
| 140 |
43 |
| * of the sitemap, and is served from the root for the same |
| 141 |
43 |
| * reason /sitemap.xml is. */ |
| 142 |
|
| cap = newAV(); |
| 143 |
43 |
| av_push(cap, newSVsv(app)); |
| 144 |
43 |
▶ | argv[0] = sv_2mortal(newSVpvs("GET")); |
Branch: 1 branch
| Branch | True | False | Total |
| argv[0] = sv_2mortal(newSVpvs("GET")); |
43 |
0 |
43 |
|
| 145 |
|
| argv[1] = sv_2mortal(newSVpvs("/robots.txt")); |
| 146 |
|
| argv[2] = sv_2mortal(punk_closure(aTHX_ pks_robots_cb, cap)); |
| 147 |
|
| argv[3] = &PL_sv_undef; |
| 148 |
|
| { |
| 149 |
43 |
▶ | HV *o = newHV(); |
Branch: 1 branch
| Branch | True | False | Total |
| HV *o = newHV(); |
43 |
0 |
43 |
|
| 150 |
86 |
▶ | (void)hv_stores(o, K_SITEMAP, newSViv(0)); |
Branch: 1 branch
| Branch | True | False | Total |
| (void)hv_stores(o, K_SITEMAP, newSViv(0)); |
43 |
0 |
43 |
|
| 151 |
43 |
▶ | argv[4] = sv_2mortal(newRV_noinc((SV *)o)); |
Branch: 1 branch
| Branch | True | False | Total |
| argv[4] = sv_2mortal(newRV_noinc((SV *)o)); |
43 |
0 |
43 |
|
| 152 |
86 |
▶ | } |
Branch: 1 branch
| Branch | True | False | Total |
| } |
43 |
0 |
43 |
|
| 153 |
43 |
▶ | r = pcx_call_meth(aTHX_ app, "route", argv, 5, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| r = pcx_call_meth(aTHX_ app, "route", argv, 5, 1); |
43 |
0 |
43 |
|
| 154 |
86 |
▶ | # uncoverable branch false |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable branch false |
43 |
0 |
43 |
|
| 155 |
43 |
▶ | # uncoverable condition right count:1 class:ignore_covered_err |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable condition right count:1 class:ignore_covered_err |
43 |
0 |
43 |
|
| 156 |
86 |
▶ | if (r) SvREFCNT_dec(r); |
Branch: 1 branch
| Branch | True | False | Total |
| if (r) SvREFCNT_dec(r); |
43 |
0 |
43 |
|
| 157 |
43 |
▶ | |
Branch: 4 branches
| Branch | True | False | Total |
|
2 |
41 |
43 |
|
2 |
0 |
2 |
|
2 |
0 |
2 |
|
2 |
0 |
2 |
|
| 158 |
2 |
| /* the `sitemap` keyword, for the URLs the route table cannot |
| 159 |
43 |
▶ | * know, and the TTL that bounds how stale they may be. */ |
Branch: 2 branches
| Branch | True | False | Total |
| * know, and the TTL that bounds how stale they may be. */ |
1 |
42 |
43 |
| * know, and the TTL that bounds how stale they may be. */ |
1 |
0 |
1 |
|
| 160 |
|
| { |
| 161 |
|
| SV *t = (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
| 162 |
|
| ? *(hv_fetchs((HV *)SvRV(opts), "ttl", 1)) : NULL; |
| 163 |
|
| SV **d = (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
| 164 |
|
| ? hv_fetchs((HV *)SvRV(opts), "disallow", 0) : NULL; |
| 165 |
43 |
▶ | SV **da = (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
Branch: 2 branches
| Branch | True | False | Total |
| SV **da = (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
3 |
40 |
43 |
| SV **da = (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
3 |
0 |
3 |
|
| 166 |
|
| ? hv_fetchs((HV *)SvRV(opts), "disallow_all", 0) : NULL; |
| 167 |
|
| SV **ag = (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) |
| 168 |
3 |
▶ | ? hv_fetchs((HV *)SvRV(opts), "agents", 0) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| ? hv_fetchs((HV *)SvRV(opts), "agents", 0) : NULL; |
3 |
0 |
3 |
| ? hv_fetchs((HV *)SvRV(opts), "agents", 0) : NULL; |
0 |
3 |
3 |
|
| 169 |
0 |
| # uncoverable condition right count:2 class:ignore_covered_err |
| 170 |
|
| # uncoverable condition right count:3 class:ignore_covered_err |
| 171 |
3 |
| # uncoverable condition right count:4 class:ignore_covered_err |
| 172 |
3 |
| if (d && *d && SvROK(*d) && SvTYPE(SvRV(*d)) == SVt_PVAV) |
| 173 |
4 |
▶ | (void)hv_stores(h, "sitemap_disallow", newSVsv(*d)); |
Branch: 1 branch
| Branch | True | False | Total |
| (void)hv_stores(h, "sitemap_disallow", newSVsv(*d)); |
2 |
2 |
4 |
|
| 174 |
2 |
| if (da && *da) (void)hv_stores(h, "sitemap_disallow_all", /* # uncoverable condition right count:2 class:ignore_covered_err */ |
| 175 |
|
| newSViv(SvTRUE(*da) ? 1 : 0)); |
| 176 |
|
| /* The user agents each group is repeated for. Checked here |
| 177 |
2 |
▶ | * rather than where the file is built, because a token with a |
Branch: 3 branches
| Branch | True | False | Total |
| * rather than where the file is built, because a token with a |
2 |
0 |
2 |
| * rather than where the file is built, because a token with a |
2 |
0 |
2 |
| * rather than where the file is built, because a token with a |
0 |
2 |
2 |
|
| 178 |
0 |
| * space in it is a typo that would otherwise be discovered as |
| 179 |
|
| * a crawler reading a directive that was never written. */ |
| 180 |
2 |
| if (ag && *ag) { /* # uncoverable condition right count:2 class:ignore_covered_err */ |
| 181 |
2 |
▶ | AV *av; |
Branch: 1 branch
| Branch | True | False | Total |
| AV *av; |
0 |
2 |
2 |
|
| 182 |
0 |
| SSize_t i, n; |
| 183 |
|
| # uncoverable branch true |
| 184 |
20 |
▶ | # uncoverable condition left count:1 class:ignore_covered_err |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable condition left count:1 class:ignore_covered_err |
19 |
1 |
20 |
|
| 185 |
19 |
▶ | # uncoverable condition left count:2 class:ignore_covered_err |
Branch: 2 branches
| Branch | True | False | Total |
| # uncoverable condition left count:2 class:ignore_covered_err |
18 |
1 |
19 |
| # uncoverable condition left count:2 class:ignore_covered_err |
18 |
0 |
18 |
|
| 186 |
18 |
▶ | if (!(SvROK(*ag) && SvTYPE(SvRV(*ag)) == SVt_PVAV)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(SvROK(*ag) && SvTYPE(SvRV(*ag)) == SVt_PVAV)) |
0 |
18 |
18 |
|
| 187 |
1 |
| croak("Punk::Plugin::Sitemap: agents is an arrayref " /* # uncoverable statement */ |
| 188 |
|
| "of user-agent tokens"); |
| 189 |
|
| av = (AV *)SvRV(*ag); |
| 190 |
|
| n = av_len(av) + 1; |
| 191 |
|
| for (i = 0; i < n; i++) { |
| 192 |
2 |
| SV **e = av_fetch(av, i, 0); |
| 193 |
|
| STRLEN l, j; |
| 194 |
42 |
▶ | const char *s; |
Branch: 3 branches
| Branch | True | False | Total |
| const char *s; |
42 |
0 |
42 |
| const char *s; |
2 |
40 |
42 |
| const char *s; |
2 |
0 |
2 |
|
| 195 |
|
| # uncoverable branch true |
| 196 |
|
| # uncoverable condition left count:1 class:ignore_covered_err |
| 197 |
42 |
| # uncoverable condition left count:2 class:ignore_covered_err |
| 198 |
|
| # uncoverable condition left count:3 class:ignore_covered_err |
| 199 |
|
| if (!(e && *e && SvOK(*e))) |
| 200 |
|
| croak("Punk::Plugin::Sitemap: agents holds a " /* # uncoverable statement */ |
| 201 |
42 |
| "user-agent token, not undef"); |
| 202 |
42 |
| s = SvPV_const(*e, l); |
| 203 |
42 |
| # uncoverable branch true |
| 204 |
42 |
| # uncoverable condition left count:1 class:ignore_covered_err |
| 205 |
42 |
▶ | if (!l) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!l) |
42 |
0 |
42 |
|
| 206 |
|
| croak("Punk::Plugin::Sitemap: an empty user-agent " /* # uncoverable statement */ |
| 207 |
|
| "token names no crawler"); |
| 208 |
|
| for (j = 0; j < l; j++) |
| 209 |
|
| # uncoverable condition left count:2 class:ignore_covered_err |
| 210 |
|
| # uncoverable condition left count:3 class:ignore_covered_err |
| 211 |
|
| if (isSPACE(s[j]) || s[j] == ':' |
| 212 |
|
| || (unsigned char)s[j] < 0x20) |
| 213 |
|
| croak("Punk::Plugin::Sitemap: '%.*s' is not a " |
| 214 |
|
| "user-agent token - a token carries no " |
| 215 |
|
| "space, colon or newline", |
| 216 |
|
| (int)l, s); |
| 217 |
|
| } |
| 218 |
|
| (void)hv_stores(h, "sitemap_agents", newSVsv(*ag)); |
| 219 |
|
| } |
| 220 |
|
| (void)hv_stores(h, "sitemap_ttl", |
| 221 |
|
| (t && SvOK(t) && SvNV(t) > 0) |
| 222 |
|
| ? newSVnv(SvNV(t)) : newSVnv(3600.0)); |
| 223 |
|
| pks_install_kw(aTHX_ app); |
| 224 |
|
| } |
| 225 |
|
| |
| 226 |
|
| /* and the build itself, at to_app */ |
| 227 |
|
| cap = newAV(); |
| 228 |
|
| av_push(cap, newSVsv(app)); |
| 229 |
|
| argv[0] = sv_2mortal(punk_closure(aTHX_ pks_mw_cb, cap)); |
| 230 |
|
| r = pcx_call_meth(aTHX_ app, "middleware", argv, 1, 1); |
| 231 |
|
| # uncoverable branch false |
| 232 |
|
| # uncoverable condition right count:1 class:ignore_covered_err |
| 233 |
|
| if (r) SvREFCNT_dec(r); |
| 234 |
|
| } |
| 235 |
|
| } |
| 236 |
|
| |
| 237 |
|
| # The rendered document for a part, or the index. Private, and what the |
| 238 |
|
| # tests parse. |
| 239 |
|
| SV * |
| 240 |
|
| _doc(class, app, n = 0) |
| 241 |
|
| SV *class |
| 242 |
|
| SV *app |
| 243 |
|
| IV n |
| 244 |
|
| CODE: |
| 245 |
|
| { |
| 246 |
26 |
| HV *h = app_hv(aTHX_ app); |
| 247 |
26 |
| SV *doc = NULL; |
| 248 |
|
| PERL_UNUSED_VAR(class); |
| 249 |
26 |
▶ | # uncoverable branch true |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable branch true |
0 |
26 |
26 |
|
| 250 |
|
| # uncoverable condition left count:1 class:ignore_covered_err |
| 251 |
|
| if (!h) XSRETURN_UNDEF; |
| 252 |
26 |
| /* the same refresh a request would trigger - a seam that behaved |
| 253 |
26 |
▶ | * differently from the serve path would prove nothing */ |
Branch: 1 branch
| Branch | True | False | Total |
| * differently from the serve path would prove nothing */ |
24 |
2 |
26 |
|
| 254 |
|
| pks_ensure(aTHX_ app); |
| 255 |
|
| if (n <= 0) { |
| 256 |
24 |
| /* /sitemap.xml: the index when there is more than one part, and |
| 257 |
24 |
▶ | * otherwise the single part itself. */ |
Branch: 2 branches
| Branch | True | False | Total |
| * otherwise the single part itself. */ |
24 |
0 |
24 |
| * otherwise the single part itself. */ |
22 |
2 |
24 |
|
| 258 |
|
| doc = app_get(aTHX_ h, "sitemap_index"); |
| 259 |
26 |
▶ | if (!(doc && SvOK(doc))) n = 1; /* # uncoverable condition left count:1 class:ignore_covered_err */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(doc && SvOK(doc))) n = 1; /* # uncoverable condition left count:1 class:ignore_covered_err */ |
24 |
2 |
26 |
|
| 260 |
24 |
| } |
| 261 |
24 |
▶ | if (n > 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (n > 0) { |
24 |
0 |
24 |
| if (n > 0) { |
24 |
0 |
24 |
|
| 262 |
48 |
▶ | SV *ps = app_get(aTHX_ h, "sitemap_parts"); |
Branch: 1 branch
| Branch | True | False | Total |
| SV *ps = app_get(aTHX_ h, "sitemap_parts"); |
24 |
0 |
24 |
|
| 263 |
24 |
▶ | AV *parts = (ps && SvROK(ps) && SvTYPE(SvRV(ps)) == SVt_PVAV) |
Branch: 1 branch
| Branch | True | False | Total |
| AV *parts = (ps && SvROK(ps) && SvTYPE(SvRV(ps)) == SVt_PVAV) |
24 |
0 |
24 |
|
| 264 |
24 |
▶ | ? (AV *)SvRV(ps) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| ? (AV *)SvRV(ps) : NULL; |
24 |
0 |
24 |
| ? (AV *)SvRV(ps) : NULL; |
24 |
0 |
24 |
|
| 265 |
|
| SV **e = parts ? av_fetch(parts, (SSize_t)(n - 1), 0) : NULL; /* # uncoverable condition right count:1 class:ignore_covered_err */ |
| 266 |
26 |
▶ | # uncoverable condition right count:1 class:ignore_covered_err |
Branch: 2 branches
| Branch | True | False | Total |
| # uncoverable condition right count:1 class:ignore_covered_err |
26 |
0 |
26 |
| # uncoverable condition right count:1 class:ignore_covered_err |
0 |
26 |
26 |
|
| 267 |
26 |
| # uncoverable condition right count:2 class:ignore_covered_err |
| 268 |
|
| doc = (e && *e) ? *e : NULL; |
| 269 |
|
| } |
| 270 |
|
| # uncoverable branch true |
| 271 |
|
| # uncoverable condition left count:1 class:ignore_covered_err |
| 272 |
|
| # uncoverable condition left count:2 class:ignore_covered_err |
| 273 |
|
| if (!(doc && SvOK(doc))) XSRETURN_UNDEF; |
| 274 |
|
| RETVAL = newSVsv(doc); |
| 275 |
|
| } |
| 276 |
|
| OUTPUT: |
| 277 |
|
| RETVAL |
| 278 |
|
| |
| 279 |
|
| # How many <urlset> parts the document split into. |
| 280 |
|
| IV |
| 281 |
|
| _parts(class, app) |
| 282 |
|
| SV *class |
| 283 |
|
| SV *app |
| 284 |
|
| CODE: |
| 285 |
|
| { |
| 286 |
3 |
| HV *h = app_hv(aTHX_ app); |
| 287 |
|
| SV *ps; |
| 288 |
|
| PERL_UNUSED_VAR(class); |
| 289 |
3 |
▶ | # uncoverable branch false |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable branch false |
3 |
0 |
3 |
|
| 290 |
3 |
▶ | # uncoverable condition right count:1 class:ignore_covered_err |
Branch: 1 branch
| Branch | True | False | Total |
| # uncoverable condition right count:1 class:ignore_covered_err |
3 |
0 |
3 |
|
| 291 |
6 |
▶ | if (h) pks_ensure(aTHX_ app); |
Branch: 3 branches
| Branch | True | False | Total |
| if (h) pks_ensure(aTHX_ app); |
3 |
0 |
3 |
| if (h) pks_ensure(aTHX_ app); |
3 |
0 |
3 |
| if (h) pks_ensure(aTHX_ app); |
0 |
3 |
3 |
|
| 292 |
6 |
▶ | ps = h ? app_get(aTHX_ h, "sitemap_parts") : NULL; /* # uncoverable condition right count:1 class:ignore_covered_err */ |
Branch: 1 branch
| Branch | True | False | Total |
| ps = h ? app_get(aTHX_ h, "sitemap_parts") : NULL; /* # uncoverable condition right count:1 class:ignore_covered_err */ |
3 |
0 |
3 |
|
| 293 |
|
| RETVAL = (ps && SvROK(ps) && SvTYPE(SvRV(ps)) == SVt_PVAV) |
| 294 |
|
| ? (IV)(av_len((AV *)SvRV(ps)) + 1) : 0; |
| 295 |
|
| } |
| 296 |
|
| OUTPUT: |
| 297 |
|
| RETVAL |
| 298 |
|
| |
| 299 |
|
| # Render now. Called from the middleware wrapper below, which Punk invokes at |
| 300 |
|
| # to_app - the only moment every route has been declared and nothing has been |
| 301 |
|
| # served yet. |
| 302 |
|
| void |
| 303 |
|
| # uncoverable statement |
| 304 |
|
| # uncoverable subroutine |
| 305 |
|
| _build(class, app) |
| 306 |
|
| SV *class |
| 307 |
|
| SV *app |
| 308 |
|
| CODE: |
| 309 |
|
| PERL_UNUSED_VAR(class); |
| 310 |
0 |
| pks_build(aTHX_ app); /* # uncoverable statement */ |
| 311 |
|
| |
| 312 |
|
| # The robots.txt body. Private, and what the tests compare against the |
| 313 |
|
| # sitemap so the two cannot be shown to disagree. |
| 314 |
|
| SV * |
| 315 |
|
| _robots(class, app) |
| 316 |
|
| SV *class |
| 317 |
|
| SV *app |
| 318 |
|
| CODE: |
| 319 |
|
| PERL_UNUSED_VAR(class); |
| 320 |
9 |
| RETVAL = pks_robots(aTHX_ app); |
| 321 |
|
| OUTPUT: |
| 322 |
|
| RETVAL |
| 323 |
|
| |
| 324 |
|
| # The candidate paths, in sorted order. Private, and the seam the tests |
| 325 |
|
| # assert through: a guarded route being ABSENT is the claim, and a claim |
| 326 |
|
| # needs something to look at. |
| 327 |
|
| void |
| 328 |
|
| _paths(class, app) |
| 329 |
|
| SV *class |
| 330 |
|
| SV *app |
| 331 |
|
| PPCODE: |
| 332 |
|
| { |
| 333 |
7 |
| AV *out = (AV *)sv_2mortal((SV *)pks_paths(aTHX_ app)); |
| 334 |
7 |
| SSize_t i, n = av_len(out) + 1; |
| 335 |
|
| PERL_UNUSED_VAR(class); |
| 336 |
7 |
▶ | EXTEND(SP, n); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, n); |
7 |
0 |
7 |
| EXTEND(SP, n); |
0 |
7 |
7 |
|
| 337 |
13 |
▶ | for (i = 0; i < n; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) |
6 |
7 |
13 |
|
| 338 |
6 |
| PUSHs(sv_2mortal(newSVsv(*av_fetch(out, i, 0)))); |
| 339 |
|
| } |
| 340 |
|
| |
| 341 |
|
| # The configured base, joined onto each path. |
| 342 |
|
| SV * |
| 343 |
|
| _base(class, app) |
| 344 |
|
| SV *class |
| 345 |
|
| SV *app |
| 346 |
|
| CODE: |
| 347 |
|
| { |
| 348 |
4 |
| HV *h = app_hv(aTHX_ app); |
| 349 |
4 |
▶ | SV *b = h ? app_get(aTHX_ h, "sitemap_base") : NULL; /* # uncoverable condition right count:1 class:ignore_covered_err */ |
Branch: 1 branch
| Branch | True | False | Total |
| SV *b = h ? app_get(aTHX_ h, "sitemap_base") : NULL; /* # uncoverable condition right count:1 class:ignore_covered_err */ |
4 |
0 |
4 |
|
| 350 |
|
| PERL_UNUSED_VAR(class); |
| 351 |
4 |
▶ | # uncoverable branch true |
Branch: 2 branches
| Branch | True | False | Total |
| # uncoverable branch true |
4 |
0 |
4 |
| # uncoverable branch true |
0 |
4 |
4 |
|
| 352 |
4 |
| # uncoverable condition left count:1 class:ignore_covered_err |
| 353 |
|
| # uncoverable condition left count:2 class:ignore_covered_err |
| 354 |
|
| if (!(b && SvOK(b))) XSRETURN_UNDEF; |
| 355 |
|
| RETVAL = newSVsv(b); |
| 356 |
|
| } |
| 357 |
|
| OUTPUT: |
| 358 |
|
| RETVAL |