aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/po.pm
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-06-25 23:18:34 +0200
committerJoey Hess <joey@kitenet.net>2010-07-04 15:27:02 -0400
commitcd03bd0b804cf4919a5d195c53bcea1f9730a51f (patch)
tree321fff84eef495691c73d61cdac29eac3f165afa /IkiWiki/Plugin/po.pm
parent8fe277c2ab42393b754fc65d966bf4ec242719ab (diff)
downloadikiwiki-cd03bd0b804cf4919a5d195c53bcea1f9730a51f.tar
ikiwiki-cd03bd0b804cf4919a5d195c53bcea1f9730a51f.tar.gz
po: added support for html pagetype
... after having audited the po4a Xml and Xhtml modules for security issues. Signed-off-by: intrigeri <intrigeri@boum.org> (cherry picked from commit a128c256a51392fcf752bf612d83a90e8c68027e)
Diffstat (limited to 'IkiWiki/Plugin/po.pm')
-rw-r--r--IkiWiki/Plugin/po.pm47
1 files changed, 37 insertions, 10 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index e85c9d760..4e6eff94f 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -848,8 +848,8 @@ sub refreshpot ($) {
my $masterfile=shift;
my $potfile=potfile($masterfile);
- my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0);
- my $doc=Locale::Po4a::Chooser::new('text',%options);
+ my $doc=Locale::Po4a::Chooser::new(po4a_type($masterfile),
+ po4a_options($masterfile));
$doc->{TT}{utf_mode} = 1;
$doc->{TT}{file_in_charset} = 'UTF-8';
$doc->{TT}{file_out_charset} = 'UTF-8';
@@ -940,10 +940,8 @@ sub percenttranslated ($) {
return gettext("N/A") unless istranslation($page);
my $file=srcfile($pagesources{$page});
my $masterfile = srcfile($pagesources{masterpage($page)});
- my %options = (
- "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
- );
- my $doc=Locale::Po4a::Chooser::new('text',%options);
+ my $doc=Locale::Po4a::Chooser::new(po4a_type($masterfile),
+ po4a_options($masterfile));
$doc->process(
'po_in_name' => [ $file ],
'file_in_name' => [ $masterfile ],
@@ -1094,10 +1092,8 @@ sub po_to_markup ($$) {
or return $fail->(sprintf(gettext("failed to write %s"), $infile));
my $masterfile = srcfile($pagesources{masterpage($page)});
- my %options = (
- "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
- );
- my $doc=Locale::Po4a::Chooser::new('text',%options);
+ my $doc=Locale::Po4a::Chooser::new(po4a_type($masterfile),
+ po4a_options($masterfile));
$doc->process(
'po_in_name' => [ $infile ],
'file_in_name' => [ $masterfile ],
@@ -1160,6 +1156,37 @@ sub isvalidpo ($) {
"to previous page to continue edit"));
}
+sub po4a_type ($) {
+ my $file = shift;
+
+ my $pagetype = pagetype($file);
+ if ($pagetype eq 'html') {
+ return 'xhtml';
+ }
+ return 'text';
+}
+
+sub po4a_options($) {
+ my $file = shift;
+
+ my %options;
+ my $pagetype = pagetype($file);
+
+ if ($pagetype eq 'html') {
+ # how to disable options is not consistent across po4a modules
+ $options{includessi} = '';
+ $options{includeexternal} = 0;
+ }
+ elsif ($pagetype eq 'mdwn') {
+ $options{markdown} = 1;
+ }
+ else {
+ $options{markdown} = 0;
+ }
+
+ return %options;
+}
+
# ,----
# | PageSpecs
# `----