Lines 97-107
subtest 'Testing themelanguage' => sub {
Link Here
|
97 |
return; |
97 |
return; |
98 |
}; |
98 |
}; |
99 |
|
99 |
|
100 |
subtest 'Testing gettemplate' => sub { |
100 |
subtest 'Testing gettemplate/badtemplatecheck' => sub { |
101 |
plan tests => 2; |
101 |
plan tests => 7; |
102 |
|
102 |
|
|
|
103 |
my $cgi = CGI->new; |
103 |
my $template; |
104 |
my $template; |
104 |
warning_like { eval { $template = C4::Templates::gettemplate( '/etc/passwd', 'opac', CGI->new, 1 ) }; warn $@ if $@; } qr/bad template/, 'Bad template check'; |
105 |
warning_like { eval { $template = C4::Templates::gettemplate( '/etc/passwd', 'opac', $cgi, 1 ) }; warn $@ if $@; } qr/bad template/, 'Bad template check'; |
105 |
is( $template ? $template->output: '', '', 'Check output' ); |
106 |
is( $template ? $template->output: '', '', 'Check output' ); |
|
|
107 |
|
108 |
# Test a few more bad paths to gettemplate triggering badtemplatecheck |
109 |
warning_like { eval { C4::Templates::gettemplate( '../topsecret.tt', 'opac', $cgi, 1 ) }; warn $@ if $@; } qr/bad template/, 'No safe chars'; |
110 |
warning_like { eval { C4::Templates::gettemplate( '/noaccess/topsecret.tt', 'opac', $cgi, 1 ) }; warn $@ if $@; } qr/bad template/, 'Directory not allowed'; |
111 |
warning_like { eval { C4::Templates::gettemplate( C4::Context->config('intrahtdocs') . '2/prog/en/modules/about.tt', 'intranet', $cgi, 1 ) }; warn $@ if $@; } qr/bad template/, 'Directory not allowed too'; |
112 |
|
113 |
# Allow templates from /tmp |
114 |
t::lib::Mocks::mock_config( 'pluginsdir', [ '/tmp' ] ); |
115 |
warning_like { eval { C4::Templates::badtemplatecheck( '/tmp/about.tt' ) }; warn $@ if $@; } undef, 'No warn on template from plugin dir'; |
116 |
# Refuse wrong extension |
117 |
warning_like { eval { C4::Templates::badtemplatecheck( '/tmp/about.tmpl' ) }; warn $@ if $@; } qr/bad template/, 'Warn on bad extension'; |
106 |
}; |
118 |
}; |
107 |
|
119 |
|
108 |
- |
|
|