[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: KSpread: too strict validation on loading
From: Norbert Andres <nandres () web ! de>
Date: 2002-08-30 17:54:39
[Download RAW message or body]
Hi,
while reading kspread_layout code I noticed, that we have very strict rules
e.g. for alignX/Y values:
if it is not in the range we understand, we just return false.
This is very nice if you think about forward compatibility: if we added
another Flag, e.g. for aligning across a selection (see Gnumeric/OpenCalc),
in KSpread 1.3 this document can't be readed anymore.
Using the attached patch it defaults to the standard value if KSpread reads in
something it can't understand.
Commit?
Norbert
["loadxml.diff" (text/x-diff)]
Index: kspread_layout.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_layout.cc,v
retrieving revision 1.93
diff -u -r1.93 kspread_layout.cc
--- kspread_layout.cc 2002/08/11 12:30:46 1.93
+++ kspread_layout.cc 2002/08/30 17:48:17
@@ -510,13 +510,10 @@
if ( !ok )
return false;
// Validation
- if ( (unsigned int)a < 1 || (unsigned int)a > 4 )
+ if ( (unsigned int)a >= 1 || (unsigned int)a <= 4 )
{
- kdDebug(36001) << "Value out of range Cell::align=" << (unsigned int)a << endl;
- return false;
+ setAlign( a );
}
- // Assignment
- setAlign( a );
}
if ( f.hasAttribute( "alignY" ) )
{
@@ -524,13 +521,10 @@
if ( !ok )
return false;
// Validation
- if ( (unsigned int)a < 1 || (unsigned int)a > 4 )
+ if ( (unsigned int)a >= 1 || (unsigned int)a <= 4 )
{
- kdDebug(36001) << "Value out of range Cell::alignY=" << (unsigned int)a << endl;
- return false;
+ setAlignY( a );
}
- // Assignment
- setAlignY( a );
}
if ( f.hasAttribute( "bgcolor" ) )
@@ -558,26 +552,20 @@
{
FloatFormat a = (FloatFormat)f.attribute("float").toInt( &ok );
if ( !ok ) return false;
- if ( (unsigned int)a < 1 || (unsigned int)a > 3 )
+ if ( (unsigned int)a >= 1 || (unsigned int)a <= 3 )
{
- kdDebug(36001) << "Value out of range Cell::float=" << (unsigned int)a << endl;
- return false;
+ setFloatFormat( a );
}
- // Assignment
- setFloatFormat( a );
}
if ( f.hasAttribute( "floatcolor" ) )
{
FloatColor a = (FloatColor)f.attribute("floatcolor").toInt( &ok );
if ( !ok ) return false;
- if ( (unsigned int)a < 1 || (unsigned int)a > 2 )
+ if ( (unsigned int)a >= 1 || (unsigned int)a <= 2 )
{
- kdDebug(36001) << "Value out of range Cell::floatcolor=" << (unsigned int)a << endl;
- return false;
+ setFloatColor( a );
}
- // Assignment
- setFloatColor( a );
}
if ( f.hasAttribute( "faktor" ) )
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic