Commit 5a1fdacb authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 335354: editparams.cgi crashes when editing the 'languages' and…

Bug 335354: editparams.cgi crashes when editing the 'languages' and 'defaultlanguage' parameters - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=wurblzap, mkanat a=LpSolit
parent c96f82df
...@@ -305,17 +305,23 @@ sub check_image_converter { ...@@ -305,17 +305,23 @@ sub check_image_converter {
} }
sub check_languages { sub check_languages {
my @languages = split /[,\s]+/, trim($_[0]); my ($lang) = @_;
my @languages = split(/[,\s]+/, trim($lang));
if(!scalar(@languages)) { if(!scalar(@languages)) {
return "You need to specify a language tag." return "You need to specify a language tag."
} }
my $templatedir = bz_locations()->{'templatedir'}; my $templatedir = bz_locations()->{'templatedir'};
my %lang_seen;
my @validated_languages;
foreach my $language (@languages) { foreach my $language (@languages) {
if( ! -d "$templatedir/$language/custom" if( ! -d "$templatedir/$language/custom"
&& ! -d "$templatedir/$language/default") { && ! -d "$templatedir/$language/default") {
return "The template directory for $language does not exist"; return "The template directory for $language does not exist";
} }
push(@validated_languages, $language) unless $lang_seen{$language}++;
} }
# Rebuild the list of language tags, avoiding duplicates.
$_[0] = join(', ', @validated_languages);
return ""; return "";
} }
......
...@@ -127,7 +127,7 @@ sub template_include_path { ...@@ -127,7 +127,7 @@ sub template_include_path {
my @supported; my @supported;
if (defined $params->{use_languages}) { if (defined $params->{use_languages}) {
@supported = $params->{use_languages}; @supported = @{$params->{use_languages}};
} }
else { else {
my @dirs = glob(bz_locations()->{'templatedir'} . "/*"); my @dirs = glob(bz_locations()->{'templatedir'} . "/*");
......
...@@ -87,7 +87,7 @@ sub getTemplateIncludePath { ...@@ -87,7 +87,7 @@ sub getTemplateIncludePath {
my $cache = Bugzilla->request_cache; my $cache = Bugzilla->request_cache;
my $lang = $cache->{'language'} || ""; my $lang = $cache->{'language'} || "";
$cache->{"template_include_path_$lang"} ||= template_include_path({ $cache->{"template_include_path_$lang"} ||= template_include_path({
use_languages => trim(Bugzilla->params->{'languages'}), use_languages => [split(/[\s,]+/, Bugzilla->params->{'languages'})],
only_language => $lang }); only_language => $lang });
return $cache->{"template_include_path_$lang"}; return $cache->{"template_include_path_$lang"};
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment