Changeset 1929

Show
Ignore:
Timestamp:
08.02.2001 14:21:17 (19 years ago)
Author:
dg5
Message:

Modified: ConvertToPlug? and HTMLPlug to handle files in binary mode to avoid

the problem of '\n' under Windows.

Location:
trunk/gsdl/perllib/plugins
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/ConvertToPlug.pm

    r1741 r1929  
    227227    my $tmp_dirname = File::Basename::dirname($conv_filename); 
    228228    my $tmp_tailname = File::Basename::basename($conv_filename); 
    229  
     229     
    230230    my $convert_to = $self->{'convert_to'}; 
    231231    my $ret_val;     
  • trunk/gsdl/perllib/plugins/HTMLPlug.pm

    r1891 r1929  
    158158 
    159159    # trap images 
     160 
    160161    $$textref =~ s/(<img[^>]*?src\s*=\s*\"?)([^\">\s]+)(\"?[^>]*>)/ 
    161162    $self->replace_images ($1, $2, $3, $base_dir, $file, $doc_obj, $cursection)/isge; 
     
    174175    my ($front, $link, $back, $base_dir,  
    175176    $file, $doc_obj, $section) = @_; 
    176  
     177     
    177178    $link =~ s/\n/ /g; 
    178      
    179179    my ($href, $hash_part, $rl) = $self->format_link ($link, $base_dir, $file); 
    180180    return $front . $self->add_file ($href, $rl, $hash_part, $base_dir, $doc_obj, $section) . $back; 
     
    235235    $filename =~ s/^[^:]*:\/\///; 
    236236    $filename = &util::filename_cat($base_dir, $filename); 
    237  
     237     
    238238    my ($ext) = $filename =~ /(\.[^\.]*)$/; 
    239239 
     
    267267 
    268268    my ($before_hash, $hash_part) = $link =~ /^([^\#]*)(\#?.*)$/; 
     269 
    269270    $hash_part = "" if !defined $hash_part; 
    270271    if (!defined $before_hash || $before_hash !~ /[\w\.\/]/) { 
     
    277278    if ($before_hash =~ s/^((?:http|ftp|file):\/\/)//i) { 
    278279    my $type = $1; 
    279             
     280 
    280281    if ($link =~ /^(http|ftp):/i) { 
    281282        # Turn url (using /) into file name (possibly using \ on windows) 
     
    299300     
    300301    } elsif ($link !~ /^(mailto|news|gopher|nntp|telnet|javascript):/i) { 
    301  
    302     if ($before_hash =~ s/^\///) { 
     302    if ($before_hash =~ s/^\/// || $before_hash =~ /\\/) { 
     303 
    303304        # the first directory will be the domain name if w3mir was used 
    304305        # to generate archives, otherwise we'll assume all files are 
    305306        # from the same site and base_dir is the root 
     307            # This is not called in Windows 
    306308        if ($self->{'w3mir'}) { 
    307309        my @dirs = split /[\/\\]/, $file; 
     
    314316        # see if link shares directory with source document 
    315317        # => turn into relative link if this is so! 
    316         my $before_hash_fix = &util::filename_cat("",$before_hash); 
    317         $before_hash_fix =~ s/^$base_dir(\\|\/)//; 
     318        my $before_hash_fix = ""; 
     319         
     320        # filename_cat appends / or \ to the beginning of the 
     321        # file pathname but in Windows we don't want to do that 
     322        if ($ENV{'GSDLOS'} =~ /^windows/i) { 
     323            $before_hash_fix = $before_hash; 
     324        } 
     325        else { 
     326            $before_hash_fix = &util::filename_cat("",$before_hash); 
     327        } 
     328 
     329        my $base_dir_win_match = $base_dir; 
     330        $base_dir_win_match =~ s/\\/\\\\/g; 
     331 
     332        $before_hash_fix =~ s/^$base_dir_win_match(\\|\/)//; 
    318333        $before_hash = $before_hash_fix; 
    319334 
    320335        } 
    321  
    322336 
    323337    } else { 
     
    328342    } 
    329343 
    330  
    331344    my $linkfilename = &util::filename_cat ($base_dir, $before_hash);  
    332345 
     
    335348        $before_hash .= "/" if (-d $linkfilename); 
    336349    } 
    337  
     350     
    338351    return ("http://" . $before_hash, $hash_part, 1); 
    339352