Skip to content

Commit

Permalink
Item12285: Single patch per file.
Browse files Browse the repository at this point in the history
SvenDowideit noted that if a user attempts to install the patch using
the patch utility, it fails because of multiple patches for the same
file are bundled together.  Break into separate files.

git-svn-id: http://svn.foswiki.org/trunk/PatchItem12285Contrib@16197 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Dec 13, 2012
1 parent 35f81b9 commit 29f4f7f
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 97 deletions.
6 changes: 4 additions & 2 deletions data/System/PatchItem12285Contrib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Foswiki vulnerability and should be installed as soon as possible. </div>

When this extension is installed, it uses the Post-installation exit to apply any patch files found in the manifest. This extension ships with a hotfix for the following items:

| *Original Issue* | *Patch File* | *Description* |
| [[http://foswiki.org/Tasks/Item12285][Item12285]] | =Item12285-001= | Addresses a vulnerability in Locale::Maketext. |
| *Original Issue* | *Patch File* | *Description* | *Applies to* |
| [[http://foswiki.org/Tasks/Item12285][Item12285]] | =Item12285-001= | Addresses a vulnerability in Locale::Maketext. | Foswiki 1.1.0 - Foswiki 1.1.2 |
| [[http://foswiki.org/Tasks/Item12285][Item12285]] | =Item12285-002= | Addresses a vulnerability in Locale::Maketext. | Foswiki 1.1.3 - Foswiki 1.1.6 |

Before any file is patched, a backup is copied to =working/configure/backup/&lt;Item12285-001-date-time&gt;=. Each file that is a candidate to be patched is backed up. If the extensions is installed multple times, a new backup is made for each run, regardless of whether or not the patch will be applied. For this patch, the following files are copied:
* =lib/Foswiki/Macros/MAKETEXT.pm=
Expand All @@ -44,6 +45,7 @@ Note: This extension was re-released with a slightly different patch. It is st
| Dependencies: | %$DEPENDENCIES% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 1.4 (12 Dec 2012) | Split patch file so it can be used with patch utility as well. |
| 1.3 (10 Dec 2012) | Re-issue with more updates. |
| 1.2 (10 Dec 2012) | Reissue with different fix. |
| 1.1 (10 Dec 2012) | Minor changes |
Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Contrib/PatchItem12285Contrib.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use warnings;
# *must* exist in this package. This should always be in the format
# $Rev$ so that Foswiki can determine the checked-in status of the
# extension.
our $VERSION = '1.3';
our $VERSION = '1.4';

# $RELEASE is used in the "Find More Extensions" automation in configure.
# It is a manually maintained string used to identify functionality steps.
Expand All @@ -31,7 +31,7 @@ our $VERSION = '1.3';
# date - a date in 1 Jun 2009 format. Three letter English month names only.
# Note: it's important that this string is exactly the same in the extension
# topic - if you use %$RELEASE% with BuildContrib this is done automatically.
our $RELEASE = '1.3';
our $RELEASE = '1.4';

our $SHORTDESCRIPTION = 'Patch a critical vulnerability in Locale::Maketext.';

Expand Down
3 changes: 2 additions & 1 deletion lib/Foswiki/Contrib/PatchItem12285Contrib/MANIFEST
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
!noci
data/System/PatchItem12285Contrib.txt 0644
lib/Foswiki/Contrib/PatchItem12285Contrib.pm 0444
working/configure/patch/Item12285-001.patch 0644 Patch to improve Store performance.
working/configure/patch/Item12285-001.patch 0644 Patch to Foswiki 1.1.0-1.1.2.
working/configure/patch/Item12285-002.patch 0644 Patch to Foswiki 1.1.3-1.1.6.
29 changes: 17 additions & 12 deletions lib/Foswiki/Contrib/PatchItem12285Contrib/POSTINSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
my $this = shift;
my $msgs = '';

my $patchFile = Foswiki::Configure::Util::mapTarget( $this->{_root}, 'working/configure/patch/Item12285-001.patch' );
foreach my $key ( grep /^working.*\.patch/, sort keys %{ $this->{_manifest} } )
{

$msgs .= "Processing $patchFile\n";
my $patchFile = Foswiki::Configure::Util::mapTarget( $this->{_root}, $key );

require Foswiki::Configure::PatchFile;
my %result = Foswiki::Configure::PatchFile::parsePatch($patchFile);
$msgs .= "Processing $patchFile\n";

$msgs .= $result{error} if ( $result{error} );
$msgs .= $result{summary} if ( $result{summary} );
require Foswiki::Configure::PatchFile;
my %result = Foswiki::Configure::PatchFile::parsePatch($patchFile);

$msgs .= $result{error} if ( $result{error} );
$msgs .= $result{summary} if ( $result{summary} );

unless ( $result{error} ) {
$msgs .=
Foswiki::Configure::PatchFile::backupTargets( $this->{_root},
\%result );
$msgs .=
Foswiki::Configure::PatchFile::applyPatch( $this->{_root}, \%result );
}

unless ( $result{error} ) {
$msgs .=
Foswiki::Configure::PatchFile::backupTargets( $this->{_root},
\%result );
$msgs .=
Foswiki::Configure::PatchFile::applyPatch( $this->{_root}, \%result );
}

return $msgs;
Expand Down
81 changes: 1 addition & 80 deletions working/configure/patch/Item12285-001.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Author: GeorgeClark <GeorgeClark@0b4bb1d4-4e5a-0410-9cc4-b2b747904278>
Date: Mon Dec 10 00:49:20 2012 +0000

Item12285: Better validations
Item12285: Better validations. This patch applies to Foswiki 1.1.0-1.1.2

~~~PATCH 72c86f0c71519caf6d26efbe174739f6 lib/Foswiki/Macros/MAKETEXT.pm (Foswiki 1.1.0 - 1.1.2)
--- /home/gac/Foswiki/Foswiki-1.1.0/lib/Foswiki/Macros/MAKETEXT.pm 2010-10-04 11:26:34.000000000 -0400
Expand Down Expand Up @@ -80,82 +80,3 @@ Date: Mon Dec 10 00:49:20 2012 +0000
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/



~~~PATCH 160f04fc478c5f9b81d2ef6c9e614074 lib/Foswiki/Macros/MAKETEXT.pm (Foswiki 1.1.3 - Foswiki 1.1.6)
--- lib/Foswiki/Macros/MAKETEXT.pm 2012-12-11 10:51:12.959268829 -0500
+++ lib/Foswiki/Macros/MAKETEXT.pm.new 2012-12-11 10:37:31.674486503 -0500
@@ -4,9 +4,19 @@
use strict;
use warnings;

+use Locale::Maketext;
+my $escape =
+ ( $Foswiki::cfg{UserInterfaceInternationalisation}
+ && $Locale::Maketext::VERSION
+ && $Locale::Maketext::VERSION < 1.23 );
+
sub MAKETEXT {
my ( $this, $params ) = @_;

+ my $max;
+ my $min;
+ my $param_error;
+
my $str = $params->{_DEFAULT} || $params->{string} || "";
return "" unless $str;

@@ -18,15 +28,22 @@
$str =~ s/~~\[/~[/g;
$str =~ s/~~\]/~]/g;

+ $max = 0;
+ $min = 1;
+ $param_error = 0;
+
# unescape parameters and calculate highest parameter number:
- my $max = 0;
- $str =~ s/~\[(\_(\d+))~\]/ $max = $2 if ($2 > $max); "[$1]"/ge;
+ $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge;
$str =~
-s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ $max = $2 if ($2 > $max); "[$1]"/ge;
+s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge;
+ return $str if ($param_error);

# get the args to be interpolated.
my $argsStr = $params->{args} || "";

+ # Escape any escapes.
+ $str =~ s#\\#\\\\#g if ($escape); # escape any escapes
+
my @args = split( /\s*,\s*/, $argsStr );

# fill omitted args with empty strings
@@ -47,6 +64,26 @@
return $result;
}

+sub _validate {
+
+ #my ( $contents, $number, $max, $min, $param_error ) = @_
+
+ $_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number
+ $_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number
+
+ if ( $_[1] > 100 ) {
+ $_[4] = 1; # Set error flag
+ return
+"<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>";
+ }
+ if ( $_[1] < 1 ) {
+ $_[4] = 1; # Set error flag
+ return
+"<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>";
+ }
+ return "[$_[0]]"; # Return the complete bracket parameter without escapes
+}
+
1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/

83 changes: 83 additions & 0 deletions working/configure/patch/Item12285-002.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Author: GeorgeClark <GeorgeClark@0b4bb1d4-4e5a-0410-9cc4-b2b747904278>
Date: Mon Dec 10 00:49:20 2012 +0000

Item12285: Better validations This patch applies to Foswiki 1.1.3 - 1.1.6


~~~PATCH 160f04fc478c5f9b81d2ef6c9e614074 lib/Foswiki/Macros/MAKETEXT.pm (Foswiki 1.1.3 - Foswiki 1.1.6)
--- lib/Foswiki/Macros/MAKETEXT.pm 2012-12-11 10:51:12.959268829 -0500
+++ lib/Foswiki/Macros/MAKETEXT.pm.new 2012-12-11 10:37:31.674486503 -0500
@@ -4,9 +4,19 @@
use strict;
use warnings;

+use Locale::Maketext;
+my $escape =
+ ( $Foswiki::cfg{UserInterfaceInternationalisation}
+ && $Locale::Maketext::VERSION
+ && $Locale::Maketext::VERSION < 1.23 );
+
sub MAKETEXT {
my ( $this, $params ) = @_;

+ my $max;
+ my $min;
+ my $param_error;
+
my $str = $params->{_DEFAULT} || $params->{string} || "";
return "" unless $str;

@@ -18,15 +28,22 @@
$str =~ s/~~\[/~[/g;
$str =~ s/~~\]/~]/g;

+ $max = 0;
+ $min = 1;
+ $param_error = 0;
+
# unescape parameters and calculate highest parameter number:
- my $max = 0;
- $str =~ s/~\[(\_(\d+))~\]/ $max = $2 if ($2 > $max); "[$1]"/ge;
+ $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge;
$str =~
-s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ $max = $2 if ($2 > $max); "[$1]"/ge;
+s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge;
+ return $str if ($param_error);

# get the args to be interpolated.
my $argsStr = $params->{args} || "";

+ # Escape any escapes.
+ $str =~ s#\\#\\\\#g if ($escape); # escape any escapes
+
my @args = split( /\s*,\s*/, $argsStr );

# fill omitted args with empty strings
@@ -47,6 +64,26 @@
return $result;
}

+sub _validate {
+
+ #my ( $contents, $number, $max, $min, $param_error ) = @_
+
+ $_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number
+ $_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number
+
+ if ( $_[1] > 100 ) {
+ $_[4] = 1; # Set error flag
+ return
+"<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>";
+ }
+ if ( $_[1] < 1 ) {
+ $_[4] = 1; # Set error flag
+ return
+"<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>";
+ }
+ return "[$_[0]]"; # Return the complete bracket parameter without escapes
+}
+
1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/

0 comments on commit 29f4f7f

Please sign in to comment.