--- loncom/lonnet/perl/lonnet.pm 2005/06/29 11:57:17 1.644 +++ loncom/lonnet/perl/lonnet.pm 2005/08/17 19:18:36 1.650.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.644 2005/06/29 11:57:17 www Exp $ +# $Id: lonnet.pm,v 1.650.2.1 2005/08/17 19:18:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1302,7 +1302,7 @@ sub userfileupload { if ($coursedoc) { my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; - if ($env{'form.folder'} =~ m/^default/) { + if ($env{'form.folder'} =~ m/^(default|supplemental)/) { return &finishuserfileupload($docuname,$docudom, $formname,$fname,$parser,$allfiles, $codebase); @@ -1368,7 +1368,7 @@ sub finishuserfileupload { } sub extract_embedded_items { - my ($filepath,$file,$allfiles,$codebase) = @_; + my ($filepath,$file,$allfiles,$codebase,$content) = @_; my @state = (); my %javafiles = ( codebase => '', @@ -1379,14 +1379,34 @@ sub extract_embedded_items { src => '', movie => '', ); - my $p = HTML::LCParser->new($filepath.'/'.$file); + my $p; + if ($content) { + $p = HTML::LCParser->new($content); + } else { + $p = HTML::LCParser->new($filepath.'/'.$file); + } while (my $t=$p->get_token()) { if ($t->[0] eq 'S') { my ($tagname, $attr) = ($t->[1],$t->[2]); push (@state, $tagname); + if (lc($tagname) eq 'allow') { + &add_filetype($allfiles,$attr->{'src'},'src'); + } if (lc($tagname) eq 'img') { &add_filetype($allfiles,$attr->{'src'},'src'); } + if (lc($tagname) eq 'script') { + if ($attr->{'archive'} =~ /\.jar$/i) { + &add_filetype($allfiles,$attr->{'archive'},'archive'); + } else { + &add_filetype($allfiles,$attr->{'src'},'src'); + } + } + if (lc($tagname) eq 'link') { + if (lc($attr->{'rel'}) eq 'stylesheet') { + &add_filetype($allfiles,$attr->{'href'},'href'); + } + } if (lc($tagname) eq 'object' || (lc($tagname) eq 'embed' && lc($state[-2]) ne 'object')) { foreach my $item (keys(%javafiles)) { @@ -2881,7 +2901,7 @@ sub allowed { # Free bre access to user's own portfolio contents my ($space,$domain,$name,$dir)=split('/',$uri); - if (($space=~/^(uploaded|ediupload)$/) && ($env{'user.name'} eq $name) && + if (($space=~/^(uploaded|editupload)$/) && ($env{'user.name'} eq $name) && ($env{'user.domain'} eq $domain) && ('portfolio' eq $dir)) { return 'F'; } @@ -4054,28 +4074,25 @@ sub unmark_as_readonly { my ($tmp)=keys(%current_permissions); if ($tmp=~/^error:/) { undef(%current_permissions); } my @readonly_files = &get_marked_as_readonly($domain,$user,$what); - foreach my $file(@readonly_files){ - my $current_locks = $current_permissions{$file}; + foreach my $file (@readonly_files) { + if (defined($file_name) && ($file_name ne $file)) { next; } + my $current_locks = $current_permissions{$file}; my @new_locks; my @del_keys; if (ref($current_locks) eq "ARRAY"){ foreach my $locker (@{$current_locks}) { my $compare=$locker; if (ref($locker)) { $compare=join('',@{$locker}) }; - if ($compare eq $symb_crs) { - if (defined($file_name) && ($file_name ne $file)) { - push(@new_locks, $what); - } - } else { - push(@new_locks, $what); + if ($compare ne $symb_crs) { + push(@new_locks, $locker); } } - if (@new_locks > 0) { + if (scalar(@new_locks) > 0) { $current_permissions{$file} = \@new_locks; } else { push(@del_keys, $file); &del('file_permissions',\@del_keys, $domain, $user); - delete $current_permissions{$file}; + delete($current_permissions{$file}); } } } @@ -5624,6 +5641,9 @@ sub filelocation { if ($file=~m:^/~:) { # is a contruction space reference $location = $file; $location =~ s:/~(.*?)/(.*):/home/$1/public_html/$2:; + } elsif ($file=~m:^/home/[^/]*/public_html/:) { + # is a correct contruction space reference + $location = $file; } elsif ($file=~/^\/*(uploaded|editupload)/) { # is an uploaded file my ($udom,$uname,$filename)= ($file=~m -^/+(?:uploaded|editupload)/+([^/]+)/+([^/]+)/+(.*)$-); @@ -5860,7 +5880,7 @@ BEGIN { } close($config); # FIXME: dev server don't want this, production servers _do_ want this - #&get_iphost(); + &get_iphost(); } sub get_iphost {