Changeset 16670

Show
Ignore:
Timestamp:
07.08.2008 13:42:35 (11 years ago)
Author:
ak19
Message:

Instead of base64 encoding the gsdl_source_filename, it now URL encodes it. GLI's DocXMLFile.java urlDecodes it now (instead of applying base64 decoding).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/doc.pm

    r16578 r16670  
    3939use ghtml; 
    4040use File::stat; 
    41 use MIME::Base64; 
    4241##use hashdoc; 
    4342use docprint; 
     
    151150    # For instance, if this meta element (gsdlsourcefilename) will be  
    152151    # used by other applications that parse doc.xml in order to locate  
    153     # gsdlsourcefilename. Therefore, the solution is to encode the real 
    154     # filename into Base64 encoding which is a binary-to-text encoding,  
    155     # meaning that the resulting string is ASCII (utf8). See also  
    156     # MIME#Content-Transfer-Encoding in Wiki. 
    157      
    158     print STDERR "******Base64 encoding the non-utf8 gsdl_source_filename $source_filename "; 
    159      
    160     # remove "import/" from path, base 64 encode just the source_filename  
    161     # (remove trailing spaces and newlines) and prefix "import/" again.  
    162     my $import_dir = "import"; 
    163     my $srcfilename = $source_filename; 
    164     $srcfilename =~ s/^$import_dir(?:\\|\/)+(.*)$/$1/; 
    165      
     152    # gsdlsourcefilename. Therefore, the solution is to URLencode the real 
     153    # filename as this is a binary-to-text encoding meaning that the  
     154    # resulting string is ASCII (utf8). 
     155     
     156    print STDERR "******URLencoding the gsdl_source_filename $source_filename "; 
     157     
     158    # URLencode just the gsdl_source_filename, not the directory. Then prepend dir  
     159    my ($srcfilename,$dirname,$suffix)  
     160    = &File::Basename::fileparse($source_filename, "\\.[^\\.]+\$"); 
    166161    print STDERR "-> $srcfilename -> "; 
    167     $srcfilename = &MIME::Base64::encode_base64($srcfilename); 
    168     $srcfilename =~ s/\s*//sg; # for some reason it adds spaces not just at end but also in middle 
    169          
    170     $source_filename = &util::filename_cat($import_dir, $srcfilename); 
     162    $srcfilename = &unicode::url_encode($srcfilename.$suffix); 
     163    $source_filename = &util::filename_cat($dirname, $srcfilename); 
    171164    print STDERR "$source_filename\n"; 
    172      
     165     
    173166    $self->set_utf8_metadata_element ($self->get_top_section(),  
    174167                 "gsdlsourcefilename",  
     
    205198    if (defined $plugin_name && $plugin_name eq "NULPlug") { 
    206199        $filename = undef; 
    207     } else { 
     200    } else { # returns the URL encoded source filename! 
    208201        $filename = $self->get_metadata_element ($self->get_top_section(), "gsdlsourcefilename"); 
    209202    } 
     
    276269    $result = `hashfile$osexe \"$filename\"`; 
    277270    ($result) = $result =~ /:\s*([0-9a-f]+)/i; 
    278  
    279271    } else { 
    280272    print STDERR "doc::_calc_OID $hashfile_exe could not be found\n"; 
     
    854846    # double check that the value is utf-8 
    855847    if (!&unicode::check_is_utf8($value)) { 
    856     print STDERR "doc::add_utf8_metadata - warning: '$field''s value $value wasn't utf8. "; 
     848    print STDERR "doc::add_utf8_metadata - warning: '$field''s value $value wasn't utf8."; 
    857849    &unicode::ensure_utf8(\$value); 
    858     print STDERR "Tried converting to utf8: $value\n"; 
     850    print STDERR " Tried converting to utf8: $value\n"; 
    859851    } 
    860852