fixed: international characters are corrupted on export

This commit is contained in:
Graham Knop 2008-12-03 00:32:43 +00:00
parent 4a88e39c21
commit f3e08f3268
3 changed files with 32 additions and 15 deletions

View file

@ -25,6 +25,7 @@
was broken. This has been fixed. As a side effect, in the Asset Manager was broken. This has been fixed. As a side effect, in the Asset Manager
the default behavior is to copy ONLY the Calendar, and none of the events. the default behavior is to copy ONLY the Calendar, and none of the events.
- fixed: filtering of rich text areas very slow for large content - fixed: filtering of rich text areas very slow for large content
- fixed: international characters are corrupted on export
7.6.4 7.6.4
- Survey now will show progress and time limit. - Survey now will show progress and time limit.

View file

@ -159,6 +159,36 @@ sub exportAssetData {
return $data; return $data;
} }
#-------------------------------------------------------------------
sub exportWriteFile {
my $self = shift;
# we have no assurance whether the exportPath is valid or not, so check it.
WebGUI::Asset->exportCheckPath($self->session);
# if we're still here, everything is well with the export path. let's make
# sure that this user can view the asset that we want to export.
unless($self->canView) {
WebGUI::Error->throw(error => "user can't view asset at " . $self->getUrl . " to export it");
}
# if we're still here, everything is well with the export path. let's get
# our destination FS path and then make any required directories.
my $dest = $self->exportGetUrlAsPath;
my $parent = $dest->parent;
eval { File::Path::mkpath($parent->absolute->stringify) };
if($@) {
WebGUI::Error->throw(error => "could not make directory " . $parent->absolute->stringify);
}
if ( ! File::Copy::copy($self->getStorageLocation->getPath($self->get('filename')), $dest->stringify) ) {
WebGUI::Error->throw(error => "can't copy " . $self->getStorageLocation->getPath($self->get('filename'))
. ' to ' . $dest->absolute->stringify . ": $!");
}
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -529,20 +559,6 @@ sub www_edit {
#------------------------------------------------------------------- #-------------------------------------------------------------------
# setStreamedFile and setRedirect do not interact well with the
# exporter. We have a separate method for this now.
sub exportHtml_view {
my $self = shift;
my $path = $self->getStorageLocation->getPath($self->get('filename'));
open my $fh, '<:raw', $path or return "";
while ( read $fh, my $block, 16384 ) {
$self->session->output->print($block, 1);
}
close $fh;
return 'chunked';
}
#--------------------------------------------------------------------
sub www_view { sub www_view {
my $self = shift; my $self = shift;
return $self->session->privilege->noAccess() unless $self->canView; return $self->session->privilege->noAccess() unless $self->canView;

View file

@ -753,7 +753,7 @@ sub exportWriteFile {
} }
# next, get the contents, open the file, and write the contents to the file. # next, get the contents, open the file, and write the contents to the file.
my $fh = eval { $dest->openw }; my $fh = eval { $dest->open('>:utf8') };
if($@) { if($@) {
WebGUI::Error->throw(error => "can't open " . $dest->absolute->stringify . " for writing: $!"); WebGUI::Error->throw(error => "can't open " . $dest->absolute->stringify . " for writing: $!");
} }