diff -ruN e-smith-quota-2.2.0.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/quota e-smith-quota-2.2.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/quota
--- e-smith-quota-2.2.0.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/quota 2008-10-07 18:37:14.000000000 +0100
+++ e-smith-quota-2.2.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/quota 2010-11-27 10:08:19.000000000 +0000
@@ -94,19 +94,19 @@
INSTRUCTIONS
- Enter the quota as an integer with optional unit
- suffix of 'K' for kilobytes, 'M' for megabytes, or 'G' for gigabytes.
+ Enter the quota with optional unit suffix of 'K' for kilobytes, 'M' for megabytes,
+ 'G' for gigabytes or 'T' for terabytes.
Entries with no suffix are assumed to be in megabytes. A setting of '0'
for either limit disables that limit for the corresponding user.
- SOFT_VAL_MUST_BE_INTEGER
- Error: limit with grace period must be an integer, optionally followed by one of the unit suffixes K, M, or G.
+ SOFT_VAL_MUST_BE_NUMBER
+ Error: limit with grace period must be a number, optionally followed by one of the unit suffixes K, M, G, or T.
- HARD_VAL_MUST_BE_INTEGER
- Error: absolute limit must be an integer, optionally followed by one of the unit suffixes K, M, or G.
+ HARD_VAL_MUST_BE_NUMBER
+ Error: absolute limit must be a number, optionally followed by one of the unit suffixes K, M, G, or T.
ERR_HARD_LT_SOFT
diff -ruN e-smith-quota-2.2.0.old/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/quota.pm e-smith-quota-2.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/quota.pm
--- e-smith-quota-2.2.0.old/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/quota.pm 2010-11-21 15:26:32.000000000 +0000
+++ e-smith-quota-2.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/quota.pm 2010-11-27 10:08:09.000000000 +0000
@@ -20,6 +20,7 @@
use esmith::FormMagick;
use esmith::cgi;
use esmith::TestUtils;
+use Scalar::Util qw(looks_like_number);
our @ISA = qw(esmith::FormMagick Exporter);
our @EXPORT = qw(
@@ -266,42 +267,39 @@
return $self->error($msg, 'Initial');
}
my $softlim = $q->param ('soft');
- unless ($softlim =~ /^(\d+)\s*[kmg]?$/i)
- {
- return $self->error('SOFT_VAL_MUST_BE_INTEGER', 'Initial');
- }
- my $value = $1;
- if($softlim =~ /g$/i)
- {
- $softlim = $self->GBtoKB($value);
- }
- elsif($softlim =~ /k$/i)
- {
- $softlim = $value;
- }
- else
+
+ unless ($softlim =~ /^(.+?)\s*([kmgt])?$/i )
{
- $softlim = $self->MBtoKB($value);
+ return $self->error('SOFT_VAL_MUST_BE_NUMBER', 'Initial');
}
+ my $value = $1;
+ unless (looks_like_number($value))
+ {
+ return $self->error('SOFT_VAL_MUST_BE_NUMBER', 'Initial');
+ }
+ my $exponent = 1; # Entries with no suffix are assumed to be in megabytes.
+ if (defined ($2))
+ {
+ $exponent = index("kmgt",lc($2));
+ }
+ $softlim = ($value * 1024 ** $exponent);
my $hardlim = $q->param ('hard');
- unless ($hardlim =~ /^(\d+)\s*[kmg]?$/i)
- {
- return $self->error('HARD_VAL_MUST_BE_INTEGER', 'Initial');
- }
- $value = $1;
- if($hardlim =~ /g$/i)
- {
- $hardlim = $self->GBtoKB($value);
- }
- elsif($hardlim =~ /k$/i)
- {
- $hardlim = $value;
- }
- else
+ unless ($hardlim =~ /^(.+?)\s*([kmgt])?$/i )
{
- $hardlim = $self->MBtoKB($value);
+ return $self->error('HARD_VAL_MUST_BE_NUMBER', 'Initial');
}
+ my $value = $1;
+ unless (looks_like_number($value))
+ {
+ return $self->error('HARD_VAL_MUST_BE_NUMBER', 'Initial');
+ }
+ my $exponent = 1; # Entries with no suffix are assumed to be in megabytes.
+ if (defined ($2))
+ {
+ $exponent = index("kmgt",lc($2));
+ }
+ $hardlim = ($value * 1024 ** $exponent);
#------------------------------------------------------------
# Make sure that soft limit is less than hard limit.