Ignore:
Timestamp:
2008-08-01T15:42:09+12:00 (16 years ago)
Author:
ak19
Message:

Work on supporting non-utf8 characters in filenames

File:
1 edited

Legend:

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

    r16392 r16632  
    937937    $link =~ s/^.*\\([^\\]+)$/$1/;
    938938    }
    939 
     939   
    940940    my ($href, $hash_part, $rl) = $self->format_link ($link, $base_dir, $file);
    941941
    942942    my $img_file =  $self->add_file ($href, $rl, $hash_part, $base_dir, $doc_obj, $section);
     943
     944    print STDERR "**** link = $link\n";
     945    print STDERR "**** href = $href\n";
     946    print STDERR "**** img_file = $img_file\n";
    943947
    944948    my $anchor_name = $img_file;
     
    10201024    $filename = &util::filename_cat($base_dir, $filename);
    10211025   
    1022     # Replace %20's in URL with a space if required. Note that the filename
    1023     # may include the %20 in some situations
    1024     if ($filename =~ /\%20/) {
     1026    # Replace %XX's in URL with decoded value if required.
     1027    # Note that the filename may include the %XX in some situations
     1028    if ($filename =~ m/\%[A-F0-9]{2}/i) {
    10251029    if (!-e $filename) {
    1026         $filename =~ s/\%20/ /g;
     1030        $filename =~ s/\%([A-F0-9]{2})/pack('C', hex($1))/ige;
    10271031    }
    10281032    }
     
    10551059    } else {
    10561060    ($newname) = $filename =~ /([^\/\\]*)$/;
     1061    # Make sure this name is a valid utf8 filename
     1062    ## &unicode::ensure_utf8(\$newname);
     1063    $newname =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
     1064
    10571065    $doc_obj->associate_file($filename, $newname, undef, $section);
    1058     return "_httpdocimg_/$newname";
    1059     }
    1060 }
     1066
     1067    my $newname_url = $newname;
     1068    $newname_url =~ s/%/%25/g;
     1069    return "_httpdocimg_/$newname_url";
     1070    }
     1071}
     1072
    10611073
    10621074
Note: See TracChangeset for help on using the changeset viewer.