Skip to content

Commit

Permalink
Item14269: fixed crash translating certain strings
Browse files Browse the repository at this point in the history
... containing bracket links
  • Loading branch information
MichaelDaum committed Jan 16, 2017
1 parent 1516587 commit 6d03605
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion data/System/MultiLingualPlugin.txt
Expand Up @@ -204,6 +204,7 @@ in his/her browser or the value of ={DefaultLanguage}= as configured to this plu
%$DEPENDENCIES%

---++ Change History
| 16 Jan 2017 | fixed crash translating strings with certain bracket links |
| 02 Sep 2016 | added support for <nop>WebLexicon |
| 31 May 2016 | added =arg&lt;N>= way of specifying arguments to =%TRANSLATE= |
| 8 Mar 2016 | fixed error using latest Locale::Country |
Expand All @@ -218,7 +219,7 @@ in his/her browser or the value of ={DefaultLanguage}= as configured to this plu
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25TOPIC%25"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2013-2016 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2013-2017 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%25TOPIC%25"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%25TOPIC%25"}%
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/MultiLingualPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MultiLingualPlugin is Copyright (C) 2013-2016 Michael Daum http://michaeldaumconsulting.com
# MultiLingualPlugin is Copyright (C) 2013-2017 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -21,8 +21,8 @@ use warnings;
use Foswiki::Func ();
use Foswiki::Plugins ();

our $VERSION = '3.00';
our $RELEASE = '02 Sep 2016';
our $VERSION = '3.01';
our $RELEASE = '16 Jan 2017';
our $SHORTDESCRIPTION = 'Support for a multi lingual Foswiki';
our $NO_PREFS_IN_TOPIC = 1;
our $core;
Expand Down
13 changes: 8 additions & 5 deletions lib/Foswiki/Plugins/MultiLingualPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MultiLingualPlugin is Copyright (C) 2013-2016 Michael Daum http://michaeldaumconsulting.com
# MultiLingualPlugin is Copyright (C) 2013-2017 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -94,15 +94,15 @@ sub preProcessMaketextParams {
sub _checkChunk {
my $chunk = shift;

writeDebug("chunk $chunk");
#writeDebug("chunk $chunk");

if ($chunk eq '[[' || $chunk eq ']]') {
if ($chunk eq '[[' || $chunk eq ']]' || $chunk eq '][') {
$chunk =~ s/(\[|\])/~$1/g;
} elsif ($chunk eq '[' || $chunk eq '') { # "[" or end
return if $in_group; # let Locale::Maketext generate the proper error message
return $chunk if $in_group; # let Locale::Maketext generate the proper error message
$in_group = 1;
} elsif ($chunk eq ']') { # "]"
return unless $in_group; # let Locale::Maketext generate the proper error message
return $chunk unless $in_group; # let Locale::Maketext generate the proper error message

$in_group = 0;
my ($method, @params) = split(/,/, $c[-1], -1);
Expand All @@ -117,12 +117,15 @@ sub preProcessMaketextParams {
return $chunk;
}


$text =~
s/(
\[\[ # starting bracket link
|
\]\] # endint bracket link
|
\]\[ # middle part of a link
|
[^\~\[\]]+ # non-~[] stuff (Capture everything else here)
|
~. # ~[, ~], ~~, ~other
Expand Down

0 comments on commit 6d03605

Please sign in to comment.