fix charset encoding for non-ascii (closes: #27)
This commit is contained in:
parent
d2190dc5f9
commit
5497fffc44
6
TODO
6
TODO
|
@ -1,3 +1,9 @@
|
|||
Maximale Anzahl von Mailinglisten definieren?
|
||||
- wird wohl von qmailadmin in der .qmailadmin-limits-Datei festgelegt
|
||||
|
||||
Infos fuer Massen-Hosting:
|
||||
http://www.fbis.ch/index-de.php?page=14&frameset=4
|
||||
|
||||
restore user input after failed list_create (especially options)
|
||||
|
||||
support for:
|
||||
|
|
|
@ -759,9 +759,20 @@ sub set_pagedata4list_common() {
|
|||
if (($q->param('file') ne '') && ($q->param('file') =~ m/^[\w-]*$/)) {
|
||||
my ($content);
|
||||
$content = $list->get_text_content($q->param('file'));
|
||||
from_to($content,$TEXT_ENCODE,'utf8'); # by ooyama for multibyte
|
||||
# get character set of current list (ignore ":Q" prefix)
|
||||
my ($charset) = split(':',$list->get_charset());
|
||||
# use default for ezmlm-idx<5.0
|
||||
$charset = 'us-ascii' if ($charset eq '');
|
||||
warn "Charset: $charset";
|
||||
my $content_utf8;
|
||||
eval { $content_utf8 = Encode::decode($charset, $content); };
|
||||
# use $content if conversion failed somehow
|
||||
if ($@) {
|
||||
$content_utf8 = $content;
|
||||
warn "Conversion failed for charset '$charset'";
|
||||
}
|
||||
$pagedata->setValue("Data.List.File.Name", $q->param('file'));
|
||||
$pagedata->setValue("Data.List.File.Content", "$content");
|
||||
$pagedata->setValue("Data.List.File.Content", "$content_utf8");
|
||||
$pagedata->setValue("Data.List.File.isDefault",
|
||||
$list->is_text_default($q->param('file')) ? 1 : 0);
|
||||
}
|
||||
|
@ -1687,15 +1698,23 @@ sub this_listaddress {
|
|||
# ------------------------------------------------------------------------
|
||||
|
||||
sub save_text {
|
||||
# Save new text in DIR/text ...
|
||||
# Save new text in DIR/text ...
|
||||
|
||||
my ($list) = new Mail::Ezmlm("$LIST_DIR/" . $q->param('list'));
|
||||
my ($content) = $q->param('content');
|
||||
from_to($content,'utf8',$TEXT_ENCODE); # by ooyama for multibyte
|
||||
unless ($list->set_text_content($q->param('file'), $content)) {
|
||||
my ($list) = new Mail::Ezmlm("$LIST_DIR/" . $q->param('list'));
|
||||
my ($content) = $q->param('content');
|
||||
my ($charset) = split(':',$list->get_charset());
|
||||
$charset = 'us-ascii' if ($charset eq '');
|
||||
my $content_encoded;
|
||||
eval { $content_encoded = Encode::encode($charset, $content); };
|
||||
if ($@) {
|
||||
$content_encoded = $content;
|
||||
warn "Conversion failed for charset '$charset'";
|
||||
}
|
||||
unless ($list->set_text_content($q->param('file'), $content_encoded)) {
|
||||
$warning = 'SaveFile';
|
||||
return (1==0);
|
||||
}
|
||||
}
|
||||
return (0==0);
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<input type="hidden" name="file" value="<?cs var:Data.List.File.Name ?>">
|
||||
|
||||
<p><textarea name="content" rows="13"
|
||||
cols="72"><?cs var:Data.List.File.Content ?></textarea></p>
|
||||
cols="72"><?cs var:html_escape(Data.List.File.Content) ?></textarea></p>
|
||||
|
||||
<input type="hidden" name="action" value="textfile_save" />
|
||||
<button type="submit" name="send" value="do"><?cs var:html_escape(Lang.Buttons.SaveFile) ?></button>
|
||||
|
|
Loading…
Reference in a new issue