Skip to content

Commit

Permalink
Handle character encoding in the VFTP server.
Browse files Browse the repository at this point in the history
The virtual FTP server now assumes that template files uploaded to it are
encoded in the user's preferred encoding. So if you have Windows gremlins in
your templates, you can set your Character Set preference to "CP1252" and it
will just work. Thanks to Phillip Smith for the report.
  • Loading branch information
theory committed Jan 19, 2010
1 parent b4f0ef8 commit 1a11119
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lib/Bric/Changes.pod
Expand Up @@ -41,6 +41,17 @@ to the database as a boolean. [David Oliveira]

=back

=head2 Improvements

=item *

The virtual FTP server now assumes that template files uploaded to it are
encoded in the user's preferred encoding. So if you have Windows gremlins in
your templates, you can set your Character Set preference to "CP1252" and it
will just work. Thanks to Phillip Smith for the report (Bug #124). [David]

=back

=head1 VERSION 1.10.8 (2009-11-14)

=head2 Improvements
Expand Down
10 changes: 7 additions & 3 deletions lib/Bric/Util/FTP/FileHandle.pm
Expand Up @@ -40,11 +40,12 @@ use strict;

################################################################################
# Programmatic Dependences
use Bric::Config qw(:ftp);
use Bric::Config qw(:ftp :l10n);
use Bric::Util::DBI qw(:all);
use Bric::Util::Time qw(:all);
use Bric::App::Authz qw(:all);
use Bric::Util::Burner;
BEGIN { require Bric::Util::CharTrans if ENCODE_OK }
use Bric::Biz::Asset::Template;
use Bric::Util::Priv::Parts::Const qw(:all);
use Bric::Util::FTP::DirHandle;
Expand Down Expand Up @@ -490,7 +491,7 @@ the name of the file ends in ".deploy".
=cut

package Bric::Util::FTP::FileHandle::IO;
use Bric::Config qw(FTP_DEBUG);
use Bric::Config qw(FTP_DEBUG ENCODE_OK);
use Bric::Util::Time qw(:all);
use Bric::Util::Event;
use Bric::Util::Priv::Parts::Const qw(:all);
Expand Down Expand Up @@ -542,7 +543,10 @@ use base 'IO::Scalar';
$ftps->check_out($template)
}

# save the new code
# Encode and save the new code
Bric::Util::CharTrans->new($user->get_pref('Character Set'))->to_utf8($sref)
if ENCODE_OK;

$template->set_data($$sref);
$template->save;

Expand Down

0 comments on commit 1a11119

Please sign in to comment.