From 34afa2c07d2defcaf683cf8d7eb486517b4fc389 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 6 Nov 2008 13:26:45 +0100 Subject: [PATCH 1/1] po: po_master_language and po_slave_languages are safe config settings ... and check their validity in checkconfig Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 13 +++++++++++-- doc/plugins/po.mdwn | 7 +++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index bdf4b2c29..5acbcd4f8 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -61,7 +61,7 @@ sub getsetup () { #{{{ 'name' => 'English' }, description => "master language (non-PO files)", - safe => 0, + safe => 1, rebuild => 1, }, po_slave_languages => { @@ -72,7 +72,7 @@ sub getsetup () { #{{{ 'de' => 'Deutsch' }, description => "slave languages (PO files)", - safe => 0, + safe => 1, rebuild => 1, }, po_translatable_pages => { @@ -92,12 +92,21 @@ sub getsetup () { #{{{ }, } #}}} +sub islanguagecode ($) { #{{{ + my $code=shift; + return ($code =~ /^[a-z]{2}$/); +} #}}} + sub checkconfig () { #{{{ foreach my $field (qw{po_master_language po_slave_languages}) { if (! exists $config{$field} || ! defined $config{$field}) { error(sprintf(gettext("Must specify %s"), $field)); } } + map { + islanguagecode($_) + or error(sprintf(gettext("%s is not a valid language code"), $_)); + } ($config{po_master_language}{code}, keys %{$config{po_slave_languages}}); if (! exists $config{po_link_to} || ! defined $config{po_link_to}) { $config{po_link_to}="default"; diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 1526798d1..f10ee1d2c 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -257,11 +257,10 @@ be fixed by something like [[todo/using_meta_titles_for_parentlinks]]. ### websetup -Which configuration settings are safe enough for websetup? +Which configuration settings are safe enough for websetup, apart of +`po_master_language` and `po_slave_languages` that already have +been checked? -> I see no problems with `po_master_language` and `po_slave_languages` -> (assuming websetup handles the hashes correctly). Would not hurt to check -> that the values of these are legal language codes, in `checkconfig`. > `po_translatable_pages` seems entirely safe. `po_link_to` w/o usedirs > causes ikiwiki to error out. If it were changed to fall back to a safe > setting in this case rather than error, it would be safe. -- 2.39.5