Changeset 16670
- Timestamp:
- 2008-08-07T13:42:35+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/doc.pm
r16578 r16670 39 39 use ghtml; 40 40 use File::stat; 41 use MIME::Base64;42 41 ##use hashdoc; 43 42 use docprint; … … 151 150 # For instance, if this meta element (gsdlsourcefilename) will be 152 151 # 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, "\\.[^\\.]+\$"); 166 161 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); 171 164 print STDERR "$source_filename\n"; 172 165 173 166 $self->set_utf8_metadata_element ($self->get_top_section(), 174 167 "gsdlsourcefilename", … … 205 198 if (defined $plugin_name && $plugin_name eq "NULPlug") { 206 199 $filename = undef; 207 } else { 200 } else { # returns the URL encoded source filename! 208 201 $filename = $self->get_metadata_element ($self->get_top_section(), "gsdlsourcefilename"); 209 202 } … … 276 269 $result = `hashfile$osexe \"$filename\"`; 277 270 ($result) = $result =~ /:\s*([0-9a-f]+)/i; 278 279 271 } else { 280 272 print STDERR "doc::_calc_OID $hashfile_exe could not be found\n"; … … 854 846 # double check that the value is utf-8 855 847 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."; 857 849 &unicode::ensure_utf8(\$value); 858 print STDERR " Tried converting to utf8: $value\n";850 print STDERR " Tried converting to utf8: $value\n"; 859 851 } 860 852
Note:
See TracChangeset
for help on using the changeset viewer.