summaryrefslogtreecommitdiff
path: root/LedgerSMB/AM.pm
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-02 04:36:31 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-02 04:36:31 +0000
commit6c2a94cb4ec73ecbd148b74cbd6c82fb2e171715 (patch)
treeb47d57b41c61f651ef8a803a1c00d9835b56cd91 /LedgerSMB/AM.pm
parent4410a3d62f37dd01feba6aaaa9a1090248aa0d6a (diff)
Adding file location checks to the template editor
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@175 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/AM.pm')
-rwxr-xr-xLedgerSMB/AM.pm44
1 files changed, 28 insertions, 16 deletions
diff --git a/LedgerSMB/AM.pm b/LedgerSMB/AM.pm
index adae27b8..142111c1 100755
--- a/LedgerSMB/AM.pm
+++ b/LedgerSMB/AM.pm
@@ -1230,10 +1230,35 @@ sub update_recurring {
}
+sub check_template_name {
+
+ my ($self, $myconfig, $form) = @_;
+
+ my @allowedsuff = qw(css tex txt html xml);
+ if ($form->{file} =~ /\.\./){
+ $form->error("Directory transversal not allowed.");
+ }
+ my $whitelisted = 0;
+ for (@allowedsuff){
+ if ($form->{file} =~ /$_$/){
+ $whitelisted = 1;
+ }
+ }
+ if (!$whitelisted){
+ $form->error("Error: File is of type that is not allowed.");
+ }
+
+ if ($form->{file} !~ /^$myconfig->{templates}/){
+ $form->error("$!: $form->{file}") unless $form->{file} =~ /^css/;
+ }
+}
+
+
sub load_template {
- my ($self, $form) = @_;
+ my ($self, $myconfig, $form) = @_;
+ $self->check_template_name(\%$myconfig, \%$form);
open(TEMPLATE, "$form->{file}") or $form->error("$form->{file} : $!");
while (<TEMPLATE>) {
@@ -1247,22 +1272,9 @@ sub load_template {
sub save_template {
- my ($self, $form) = @_;
-
- my @allowedsuff = qw(css tex txt html xml);
- if ($form->{file} =~ /\.\./){
- $form->error("Directory transversal not allowed.");
- }
- my $whitelisted = 0;
- for (@allowedsuff){
- if ($form->{file} =~ /$_$/){
- $whitelisted = 1;
- }
- }
- if (!$whitelisted){
- $form->error("Error: File is of type that is not allowed.");
- }
+ my ($self, $myconfig, $form) = @_;
+ $self->check_template_name(\%$myconfig, \%$form);
open(TEMPLATE, ">$form->{file}") or $form->error("$form->{file} : $!");
# strip