Skip to content

Commit

Permalink
Item2000: TablePlugin crashes when sorting a field with the number 0
Browse files Browse the repository at this point in the history
Item2001: TablePlugin: Numbers with suffix do not sort if negative


git-svn-id: http://svn.foswiki.org/branches/Release01x00@4760 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KennethLavrsen authored and KennethLavrsen committed Sep 3, 2009
1 parent 99c1f81 commit 809357c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions TablePlugin/data/System/TablePlugin.txt
Expand Up @@ -116,6 +116,7 @@ Information for programmers.
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- specify latest version first -->&nbsp; |
| 03 Sep 2009 | 1.041: Kenneth Lavrsen: Fix for crash when cell contains the number 0. Allow sorting of negative numbers even when suffixed with unit. Treat whitespace as zero if pure numerical context. |
| 02 Sep 2009 | 1.040: Kenneth Lavrsen: Fixed the fix of parsing date-time columns so that plain numbers are not interpreted as dates causing wrong sorting |
| 03 Jun 2009 | 1.039: Michael Daum: fixed parsing date-time columns |
| 19 Apr 2009 | 1.038: Removed support for settings in the plugin topic which is a bad idea anyway as they get overwritten at each Foswiki upgrade. Define the global settings in <nop>%USERSWEB%.SitePreferences instead. <br />Fixed an issue where TablePlugin produced invalid css if no 'px' or '%' is passed in a size parameter. <br />Small refactoring in style attribute handling. |
Expand Down
2 changes: 1 addition & 1 deletion TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm
Expand Up @@ -32,7 +32,7 @@ use Foswiki::Plugins (); # For the API version
use vars qw( $topic $installWeb $initialised );

our $VERSION = '$Rev$';
our $RELEASE = '1.040';
our $RELEASE = '1.041';
our $SHORTDESCRIPTION =
'Control attributes of tables and sorting of table columns';
our $NO_PREFS_IN_TOPIC = 1;
Expand Down
10 changes: 5 additions & 5 deletions TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm
Expand Up @@ -507,12 +507,12 @@ sub _convertToNumberAndDate {
return (0, 0);
}

my $num = 0;
my $date = 0;
my $num = undef;
my $date = undef;

# Unless the table cell is a pure number
# we test if it is a date.
if ( $text =~ /^\s*([0-9]+)(\.[0-9]+)?\s*$/ ) {
if ( $text =~ /^\s*-?[0-9]+(\.[0-9]+)?\s*$/ ) {
$num = $text;
}
else {
Expand All @@ -525,7 +525,7 @@ sub _convertToNumberAndDate {

unless ($date) {
$date = undef;
if ( $text =~ /^\s*([0-9]+)(\.[0-9]+)?/ ) {
if ( $text =~ /^\s*(-?[0-9]+)(\.[0-9]+)?/ ) {
# for example for attachment sizes: 1.1 K
# but also for other strings that start with a number
my $num1 = $1 || 0;
Expand Down Expand Up @@ -739,7 +739,7 @@ sub _guessColumnType {
my $date = '';
my $columnIsValid = 0;
foreach my $row (@curTable) {
next if ( !$row->[$col]->{text} );
next if ( $row->[$col]->{text} =~ /^\s*$/ );

# else
$columnIsValid = 1;
Expand Down

0 comments on commit 809357c

Please sign in to comment.