Revision dc3cd296
Von Moritz Bunkus vor fast 17 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
376 | 376 |
|
377 | 377 |
} |
378 | 378 |
|
379 |
sub quote_html { |
|
380 |
$main::lxdebug->enter_sub(2); |
|
381 |
|
|
382 |
my ($self, $str) = @_; |
|
383 |
|
|
384 |
my %replace = |
|
385 |
('order' => ['&', '"', '<', '>'], |
|
386 |
'<' => '<', |
|
387 |
'>' => '>', |
|
388 |
'"' => '"', |
|
389 |
'&' => '&', |
|
390 |
); |
|
391 |
|
|
392 |
map({ $str =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} }); |
|
393 |
|
|
394 |
$main::lxdebug->leave_sub(2); |
|
395 |
|
|
396 |
return $str; |
|
397 |
} |
|
398 |
|
|
399 |
sub unquote_html { |
|
400 |
$main::lxdebug->enter_sub(2); |
|
401 |
|
|
402 |
my ($self, $str) = @_; |
|
403 |
|
|
404 |
my %replace = |
|
405 |
('ä' => '?', |
|
406 |
'ö' => '?', |
|
407 |
'ü' => '?', |
|
408 |
'Ä' => '?', |
|
409 |
'Ö' => '?', |
|
410 |
'Ü' => '?', |
|
411 |
'ß' => '?', |
|
412 |
'>' => '>', |
|
413 |
'<' => '<', |
|
414 |
'"' => '"', |
|
415 |
); |
|
416 |
|
|
417 |
map { $str =~ s/\Q$_\E/$replace{$_}/g; } keys %replace; |
|
418 |
$str =~ s/\&/\&/g; |
|
419 |
|
|
420 |
$main::lxdebug->leave_sub(2); |
|
421 |
|
|
422 |
return $str; |
|
423 |
} |
|
424 |
|
|
425 |
|
|
426 | 379 |
sub hide_form { |
427 | 380 |
my $self = shift; |
428 | 381 |
|
... | ... | |
1279 | 1232 |
sub generate_attachment_filename { |
1280 | 1233 |
my ($self) = @_; |
1281 | 1234 |
|
1282 |
my $attachment_filename = $self->unquote_html($self->get_formname_translation());
|
|
1235 |
my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation());
|
|
1283 | 1236 |
my $prefix = |
1284 | 1237 |
(first { $self->{type} eq $_ } qw(invoice credit_note)) ? 'inv' |
1285 | 1238 |
: ($self->{type} =~ /_quotation$/) ? 'quo' |
... | ... | |
1293 | 1246 |
: $self->{format} =~ /opendocument/i ? ".odt" |
1294 | 1247 |
: $self->{format} =~ /html/i ? ".html" |
1295 | 1248 |
: ""); |
1249 |
$attachment_filename = lc $main::locale->quote_special_chars('filenames', $attachment_filename); |
|
1296 | 1250 |
$attachment_filename =~ s/ /_/g; |
1297 |
my %umlaute = ( "?" => "ae", "?" => "oe", "?" => "ue", |
|
1298 |
"?" => "Ae", "?" => "Oe", "?" => "Ue", "?" => "ss"); |
|
1299 |
map { $attachment_filename =~ s/$_/$umlaute{$_}/g } keys %umlaute; |
|
1300 | 1251 |
} else { |
1301 | 1252 |
$attachment_filename = ""; |
1302 | 1253 |
} |
SL/Inifile.pm | ||
---|---|---|
40 | 40 |
sub new { |
41 | 41 |
$main::lxdebug->enter_sub(); |
42 | 42 |
|
43 |
my ($type, $file) = @_; |
|
43 |
my ($type, $file, %options) = @_;
|
|
44 | 44 |
|
45 | 45 |
my $id = ""; |
46 | 46 |
my $skip; |
... | ... | |
54 | 54 |
while (<FH>) { |
55 | 55 |
chomp; |
56 | 56 |
|
57 |
# strip comments |
|
58 |
s/#.*//g; |
|
57 |
if (!$options{verbatim}) { |
|
58 |
# strip comments |
|
59 |
s/\#.*//; |
|
59 | 60 |
|
60 |
# remove any trailing whitespace |
|
61 |
s/^\s*//; |
|
62 |
s/\s*$//; |
|
61 |
# remove any trailing whitespace |
|
62 |
s/^\s*//; |
|
63 |
s/\s*$//; |
|
64 |
} else { |
|
65 |
next if (m/^\s*\#/); |
|
66 |
} |
|
63 | 67 |
|
64 | 68 |
next unless $_; |
65 | 69 |
|
SL/Locale.pm | ||
---|---|---|
40 | 40 |
|
41 | 41 |
use SL::LXDebug; |
42 | 42 |
use SL::Common; |
43 |
use SL::Inifile; |
|
43 | 44 |
|
44 | 45 |
sub new { |
45 | 46 |
$main::lxdebug->enter_sub(); |
46 | 47 |
|
47 | 48 |
my ($type, $country, $NLS_file) = @_; |
49 |
|
|
48 | 50 |
my $self = {}; |
51 |
bless $self, $type; |
|
49 | 52 |
|
50 | 53 |
$country =~ s|.*/||; |
51 | 54 |
$country =~ s|\.||g; |
52 | 55 |
$NLS_file =~ s|.*/||; |
53 | 56 |
|
57 |
$self->_init($country, $NLS_file); |
|
58 |
|
|
59 |
$main::lxdebug->leave_sub(); |
|
60 |
|
|
61 |
return $self; |
|
62 |
} |
|
63 |
|
|
64 |
sub _init { |
|
65 |
my $self = shift; |
|
66 |
my $country = shift; |
|
67 |
my $NLS_file = shift; |
|
68 |
|
|
54 | 69 |
if ($country && -d "locale/$country") { |
55 | 70 |
local *IN; |
56 | 71 |
$self->{countrycode} = $country; |
... | ... | |
70 | 85 |
$self->{charset} = Common::DEFAULT_CHARSET; |
71 | 86 |
} |
72 | 87 |
|
88 |
$self->_read_special_chars_file($country); |
|
89 |
|
|
73 | 90 |
my $db_charset = $main::dbcharset || Common::DEFAULT_CHARSET; |
74 | 91 |
|
75 | 92 |
$self->{iconv} = Text::Iconv->new($self->{charset}, $db_charset); |
... | ... | |
85 | 102 |
"September", "October", "November", "December"); |
86 | 103 |
push @{ $self->{SHORT_MONTH} }, |
87 | 104 |
(qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)); |
105 |
} |
|
88 | 106 |
|
89 |
$main::lxdebug->leave_sub(); |
|
107 |
sub _handle_markup { |
|
108 |
my $self = shift; |
|
109 |
my $str = shift; |
|
90 | 110 |
|
91 |
bless $self, $type; |
|
111 |
if ($str eq "\\n") { |
|
112 |
return "\n"; |
|
113 |
} elsif ($str eq "\\r") { |
|
114 |
return "\r"; |
|
115 |
} |
|
116 |
|
|
117 |
$str =~ s/\\x(..)/chr(hex($1))/eg; |
|
118 |
$str =~ s/\\(.)/$1/g; |
|
119 |
|
|
120 |
return $str; |
|
121 |
} |
|
122 |
|
|
123 |
sub _read_special_chars_file { |
|
124 |
my $self = shift; |
|
125 |
my $country = shift; |
|
126 |
|
|
127 |
if (! -f "locale/$country/special_chars") { |
|
128 |
$self->{special_chars_map} = {}; |
|
129 |
return; |
|
130 |
} |
|
131 |
|
|
132 |
$self->{special_chars_map} = Inifile->new("locale/$country/special_chars", 'verbatim' => 1); |
|
133 |
|
|
134 |
foreach my $format (keys %{ $self->{special_chars_map} }) { |
|
135 |
next if (($format eq 'FILE') || ($format eq 'ORDER') || (ref $self->{special_chars_map}->{$format} ne 'HASH')); |
|
136 |
|
|
137 |
if ($format ne lc $format) { |
|
138 |
$self->{special_chars_map}->{lc $format} = $self->{special_chars_map}->{$format}; |
|
139 |
delete $self->{special_chars_map}->{$format}; |
|
140 |
$format = lc $format; |
|
141 |
} |
|
142 |
|
|
143 |
my $scmap = $self->{special_chars_map}->{$format}; |
|
144 |
my $order = $scmap->{order}; |
|
145 |
delete $scmap->{order}; |
|
146 |
|
|
147 |
foreach my $key (keys %{ $scmap }) { |
|
148 |
$scmap->{$key} = $self->_handle_markup($scmap->{$key}); |
|
149 |
|
|
150 |
my $new_key = $self->_handle_markup($key); |
|
151 |
|
|
152 |
if ($key ne $new_key) { |
|
153 |
$scmap->{$new_key} = $scmap->{$key}; |
|
154 |
delete $scmap->{$key}; |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
$self->{special_chars_map}->{"${format}-reverse"} = { reverse %{ $scmap } }; |
|
159 |
|
|
160 |
$scmap->{order} = [ map { $self->_handle_markup($_) } split m/\s+/, $order ]; |
|
161 |
$self->{special_chars_map}->{"${format}-reverse"}->{order} = [ grep { $_ } map { $scmap->{$_} } reverse @{ $scmap->{order} } ]; |
|
162 |
} |
|
92 | 163 |
} |
93 | 164 |
|
94 | 165 |
sub text { |
... | ... | |
270 | 341 |
return $output_format; |
271 | 342 |
} |
272 | 343 |
|
344 |
sub quote_special_chars { |
|
345 |
my $self = shift; |
|
346 |
my $format = lc shift; |
|
347 |
my $string = shift; |
|
348 |
|
|
349 |
if ($self->{special_chars_map} && $self->{special_chars_map}->{$format} && $self->{special_chars_map}->{$format}->{order}) { |
|
350 |
my $scmap = $self->{special_chars_map}->{$format}; |
|
351 |
|
|
352 |
map { $string =~ s/\Q${_}\E/$scmap->{$_}/g } @{ $scmap->{order} }; |
|
353 |
} |
|
354 |
|
|
355 |
return $string; |
|
356 |
} |
|
357 |
|
|
358 |
sub unquote_special_chars { |
|
359 |
my $self = shift; |
|
360 |
my $format = shift; |
|
361 |
|
|
362 |
return $self->quote_special_chars("${format}-reverse", shift); |
|
363 |
} |
|
364 |
|
|
365 |
sub remap_special_chars { |
|
366 |
my $self = shift; |
|
367 |
my $src_format = shift; |
|
368 |
my $dst_format = shift; |
|
369 |
|
|
370 |
return $self->quote_special_chars($dst_format, $self->quote_special_chars("${src_format}-reverse", shift)); |
|
371 |
} |
|
372 |
|
|
273 | 373 |
1; |
SL/ReportGenerator.pm | ||
---|---|---|
60 | 60 |
|
61 | 61 |
$self->set_options(@_) if (@_); |
62 | 62 |
|
63 |
$self->_init_escaped_strings_map(); |
|
64 |
|
|
65 | 63 |
return $self; |
66 | 64 |
} |
67 | 65 |
|
68 |
sub _init_escaped_strings_map { |
|
69 |
my $self = shift; |
|
70 |
|
|
71 |
$self->{escaped_strings_map} = { |
|
72 |
'ä' => '?', |
|
73 |
'ö' => '?', |
|
74 |
'ü' => '?', |
|
75 |
'Ä' => '?', |
|
76 |
'Ö' => '?', |
|
77 |
'Ü' => '?', |
|
78 |
'ß' => '?', |
|
79 |
'>' => '>', |
|
80 |
'<' => '<', |
|
81 |
'"' => '"', |
|
82 |
}; |
|
83 |
|
|
84 |
my $iconv = $main::locale->{iconv_iso8859}; |
|
85 |
|
|
86 |
if ($iconv) { |
|
87 |
map { $self->{escaped_strings_map}->{$_} = $iconv->convert($self->{escaped_strings_map}->{$_}) } keys %{ $self->{escaped_strings_map} }; |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 | 66 |
sub set_columns { |
92 | 67 |
my $self = shift; |
93 | 68 |
my %columns = @_; |
... | ... | |
277 | 252 |
my $self = shift; |
278 | 253 |
my $value = shift; |
279 | 254 |
|
280 |
$value = $self->{form}->quote_html($value);
|
|
255 |
$value = $main::locale->quote_special_chars('HTML', $value);
|
|
281 | 256 |
$value =~ s/\r//g; |
282 | 257 |
$value =~ s/\n/<br>/g; |
283 | 258 |
|
... | ... | |
767 | 742 |
} |
768 | 743 |
|
769 | 744 |
sub unescape_string { |
770 |
my $self = shift; |
|
771 |
my $text = shift; |
|
772 |
|
|
773 |
foreach my $key (keys %{ $self->{escaped_strings_map} }) { |
|
774 |
$text =~ s/\Q$key\E/$self->{escaped_strings_map}->{$key}/g; |
|
775 |
} |
|
745 |
my $self = shift; |
|
746 |
my $text = shift; |
|
747 |
my $iconv = $main::locale->{iconv}; |
|
776 | 748 |
|
777 |
$text =~ s/\Q&\E/&/g; |
|
749 |
$text = $main::locale->unquote_special_chars('HTML', $text); |
|
750 |
$text = $main::locale->{iconv}->convert($text) if ($main::locale->{iconv}); |
|
778 | 751 |
|
779 | 752 |
return $text; |
780 | 753 |
} |
SL/Template.pm | ||
---|---|---|
99 | 99 |
my ($self, $variable) = @_; |
100 | 100 |
my $form = $self->{"form"}; |
101 | 101 |
|
102 |
my %replace = |
|
103 |
('order' => [quotemeta("\\"), |
|
104 |
'<pagebreak>', |
|
105 |
'&', quotemeta("\n"), |
|
106 |
'"', '\$', '%', '_', '#', quotemeta('^'), |
|
107 |
'{', '}', '<', '>', '?', "\r", '?', '\xe1', |
|
108 |
'?', '?', |
|
109 |
|
|
110 |
], |
|
111 |
quotemeta("\\") => '\\textbackslash ', |
|
112 |
'<pagebreak>' => '', |
|
113 |
'"' => "''", |
|
114 |
'&' => '\&', |
|
115 |
'\$' => '\$', |
|
116 |
'%' => '\%', |
|
117 |
'_' => '\_', |
|
118 |
'#' => '\#', |
|
119 |
'{' => '\{', |
|
120 |
'}' => '\}', |
|
121 |
'<' => '$<$', |
|
122 |
'>' => '$>$', |
|
123 |
'?' => '\pounds ', |
|
124 |
"\r" => "", |
|
125 |
'?' => '$\pm$', |
|
126 |
'\xe1' => '$\bullet$', |
|
127 |
quotemeta('^') => '\^\\', |
|
128 |
quotemeta("\n") => '\newline ', |
|
129 |
'?' => '$^2$', |
|
130 |
'?' => '$^3$', |
|
131 |
); |
|
132 |
|
|
133 |
map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} }); |
|
102 |
$variable = $main::locale->quote_special_chars('Template/LaTeX', $variable); |
|
134 | 103 |
|
135 | 104 |
# Allow some HTML markup to be converted into the output format's |
136 | 105 |
# corresponding markup code, e.g. bold or italic. |
... | ... | |
594 | 563 |
my ($self, $variable) = @_; |
595 | 564 |
my $form = $self->{"form"}; |
596 | 565 |
|
597 |
my %replace = |
|
598 |
('order' => ['<', '>', quotemeta("\n")], |
|
599 |
'<' => '<', |
|
600 |
'>' => '>', |
|
601 |
quotemeta("\n") => '<br>', |
|
602 |
); |
|
603 |
|
|
604 |
map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} }); |
|
566 |
$variable = $main::locale->quote_special_chars('Template/HTML', $variable); |
|
605 | 567 |
|
606 | 568 |
# Allow some HTML markup to be converted into the output format's |
607 | 569 |
# corresponding markup code, e.g. bold or italic. |
... | ... | |
1342 | 1304 |
my $form = $self->{"form"}; |
1343 | 1305 |
my $iconv = $self->{"iconv"}; |
1344 | 1306 |
|
1345 |
my %replace = |
|
1346 |
('order' => ['&', '<', '>', '"', "'", |
|
1347 |
'\x80', # Euro |
|
1348 |
quotemeta("\n"), quotemeta("\r")], |
|
1349 |
'<' => '<', |
|
1350 |
'>' => '>', |
|
1351 |
'"' => '"', |
|
1352 |
"'" => ''', |
|
1353 |
'&' => '&', |
|
1354 |
'\x80' => chr(0xa4), # Euro |
|
1355 |
quotemeta("\n") => '<text:line-break/>', |
|
1356 |
quotemeta("\r") => '', |
|
1357 |
); |
|
1358 |
|
|
1359 |
map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} }); |
|
1307 |
$variable = $main::locale->quote_special_chars('Template/OpenDocument', $variable); |
|
1360 | 1308 |
|
1361 | 1309 |
# Allow some HTML markup to be converted into the output format's |
1362 | 1310 |
# corresponding markup code, e.g. bold or italic. |
... | ... | |
1409 | 1357 |
my ($self, $variable) = @_; |
1410 | 1358 |
my $form = $self->{"form"}; |
1411 | 1359 |
|
1412 |
my %replace = |
|
1413 |
('order' => ['<', '>', quotemeta("\n")], |
|
1414 |
'<' => '<', |
|
1415 |
'>' => '>', |
|
1416 |
quotemeta("\n") => '<br>', |
|
1417 |
); |
|
1418 |
|
|
1419 |
map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} }); |
|
1360 |
$variable = $main::locale->quote_special_chars('Template/XML', $variable); |
|
1420 | 1361 |
|
1421 | 1362 |
# Allow no markup to be converted into the output format |
1422 | 1363 |
my @markup_replace = ('b', 'i', 's', 'u', 'sub', 'sup'); |
bin/mozilla/bp.pl | ||
---|---|---|
608 | 608 |
|
609 | 609 |
$form->get_lists(printers=>"ALL_PRINTERS"); |
610 | 610 |
print qq|<select name="printer">|; |
611 |
print map(qq|<option value="$_->{id}">| . $form->quote_html($_->{printer_description}) . qq|</option>|, @{ $form->{ALL_PRINTERS} });
|
|
611 |
print map(qq|<option value="$_->{id}">| . H($_->{printer_description}) . qq|</option>|, @{ $form->{ALL_PRINTERS} });
|
|
612 | 612 |
print qq|</select>|; |
613 | 613 |
|
614 | 614 |
# } |
bin/mozilla/common.pl | ||
---|---|---|
328 | 328 |
# ------------------------------------------------------------------------- |
329 | 329 |
|
330 | 330 |
sub H { |
331 |
return $form->quote_html($_[0]);
|
|
331 |
return $locale->quote_special_chars('HTML', $_[0]);
|
|
332 | 332 |
} |
333 | 333 |
|
334 | 334 |
sub Q { |
335 |
return $form->quote($_[0]);
|
|
335 |
return $locale->quote_special_chars('URL@HTML', $_[0]);
|
|
336 | 336 |
} |
337 | 337 |
|
338 | 338 |
sub E { |
bin/mozilla/rp.pl | ||
---|---|---|
1984 | 1984 |
|
1985 | 1985 |
$auth->assert('general_ledger'); |
1986 | 1986 |
|
1987 |
my %replacements = |
|
1988 |
( |
|
1989 |
"?" => "ae", "?" => "oe", "?" => "ue", |
|
1990 |
"?" => "Ae", "?" => "Oe", "?" => "Ue", |
|
1991 |
"?" => "ss", |
|
1992 |
" " => "_" |
|
1993 |
); |
|
1994 |
|
|
1995 |
foreach my $key (keys %replacements) { |
|
1996 |
my $new_key = SL::Iconv::convert("ISO-8859-15", $dbcharset, $key); |
|
1997 |
$replacements{$new_key} = $replacements{$key} if $new_key ne $key; |
|
1998 |
} |
|
1999 |
|
|
2000 | 1987 |
$form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1); |
2001 | 1988 |
|
2002 | 1989 |
$form->{templates} = "$myconfig{templates}"; |
... | ... | |
2075 | 2062 |
$form->format_amount(\%myconfig, $form->{"${_}total"}, 2) |
2076 | 2063 |
} (c0, c30, c60, c90, ""); |
2077 | 2064 |
|
2078 |
$form->{attachment_filename} = $locale->text("Statement") . "_$form->{todate}.$attachment_suffix";
|
|
2079 |
map({ $form->{attachment_filename} =~ s/$_/$replacements{$_}/g; } keys(%replacements));
|
|
2065 |
$form->{attachment_filename} = $locale->quote_special_chars('filenames', $locale->text("Statement") . "_$form->{todate}.$attachment_suffix");
|
|
2066 |
$form->{attachment_filename} =~ s/\s+/_/g;
|
|
2080 | 2067 |
|
2081 | 2068 |
$form->parse_template(\%myconfig, $userspath); |
2082 | 2069 |
|
locale/de/special_chars | ||
---|---|---|
1 |
[HTML] |
|
2 |
order=& ? ? ? ? ? ? ? " < > |
|
3 |
?=ä |
|
4 |
?=ö |
|
5 |
?=ü |
|
6 |
?=Ä |
|
7 |
?=Ö |
|
8 |
?=Ü |
|
9 |
?=ß |
|
10 |
"=" |
|
11 |
&=& |
|
12 |
<=< |
|
13 |
>=&ht; |
|
14 |
|
|
15 |
[URL@HTML] |
|
16 |
"=" |
|
17 |
|
|
18 |
[XUL] |
|
19 |
order=& |
|
20 |
&=" |
|
21 |
|
|
22 |
[Template/HTML] |
|
23 |
order=< > \n |
|
24 |
<=< |
|
25 |
>=> |
|
26 |
\n=<br> |
|
27 |
|
|
28 |
[Template/XML] |
|
29 |
order=< > \n |
|
30 |
<=< |
|
31 |
>=> |
|
32 |
\n=<br> |
|
33 |
|
|
34 |
[Template/LaTeX] |
|
35 |
order=\\ <pagebreak> & \n \r " $ % _ # ^ { } < > ? ? \xe1 ? ? |
|
36 |
\\=\\textbackslash |
|
37 |
<pagebreak>= |
|
38 |
"='' |
|
39 |
&=\\& |
|
40 |
$=\\$ |
|
41 |
%=\\% |
|
42 |
_=\\_ |
|
43 |
#=\\# |
|
44 |
{=\\{ |
|
45 |
}=\\} |
|
46 |
<=$<$ |
|
47 |
>=$>$ |
|
48 |
?=\\pounds |
|
49 |
\n=\\newline |
|
50 |
\r= |
|
51 |
?=$\\pm$ |
|
52 |
\xe1=$\\bullet$ |
|
53 |
^=\\^\\ |
|
54 |
?=$^2$ |
|
55 |
?=$^3$ |
|
56 |
|
|
57 |
[Template/OpenDocument] |
|
58 |
order=& < > " ' \x80 \n \r |
|
59 |
<=< |
|
60 |
>=> |
|
61 |
"=" |
|
62 |
'=' |
|
63 |
&=& |
|
64 |
# Euro sign: |
|
65 |
\x80=\xa4 |
|
66 |
\n=<text:line-break/> |
|
67 |
\r= |
|
68 |
|
|
69 |
[filenames] |
|
70 |
?=ae |
|
71 |
?=oe |
|
72 |
?=ue |
|
73 |
?=Ae |
|
74 |
?=Oe |
|
75 |
?=Ue |
|
76 |
?=ss |
Auch abrufbar als: Unified diff
Das Quoten/Unquoten von speziellen Zeichen in zentrale Hilfsfunktionen in Locale verlagert.