summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-08-11 20:03:36 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-08-15 18:25:52 +0200
commitc5dbe94eb71acd9ab19cd9a8d561dd75da82d3d7 (patch)
tree2365c04d1bcbaa7c49418fb742f44362909d005d /sc
parentc2c2f74e26c8a7da78a8daee4671e1cb14509c12 (diff)
Resolves: tdf#143809 "INF" may be a named expression or DB area name
... to not be caught by rtl::math::stringToDouble() handling XMLSchema-2 "INF" and "NaN" and set as error. Change-Id: I9bf7aad416a69d4c3c0d49d6c80168097040a3e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120337 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit b37fd7f38165dadc5b1a674b73f4b18824e4789e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120435 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/compiler.hxx1
-rw-r--r--sc/source/core/tool/compiler.cxx37
2 files changed, 31 insertions, 7 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index b051f3ad4b4e..8ff420001d2b 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -344,6 +344,7 @@ private:
bool IsColRowName( const OUString& );
bool IsBoolean( const OUString& );
void AutoCorrectParsedSymbol();
+ const ScRangeData* GetRangeData( SCTAB& rSheet, const OUString& rUpperName ) const;
void AdjustSheetLocalNameRelReferences( SCTAB nDelta );
void SetRelNameReference();
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 274205f5734b..b2b008b13d55 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3093,7 +3093,24 @@ bool ScCompiler::IsValue( const OUString& rSym )
return false;
}
if (eStatus == rtl_math_ConversionStatus_OutOfRange)
+ {
+ // rtl::math::stringToDouble() recognizes XMLSchema-2 "INF" and
+ // "NaN" (case sensitive) that could be named expressions or DB
+ // areas as well.
+ // rSym is already upper so "NaN" is not possible here.
+ if (!std::isfinite(fVal) && rSym == "INF")
+ {
+ SCTAB nSheet = -1;
+ if (GetRangeData( nSheet, rSym))
+ return false;
+ if (rDoc.GetDBCollection()->getNamedDBs().findByUpperName(rSym))
+ return false;
+ }
+ /* TODO: is there a specific reason why we don't accept an infinity
+ * value that would raise an error in the interpreter, instead of
+ * setting the hard error at the token array already? */
SetError( FormulaError::IllegalArgument );
+ }
maRawToken.SetDouble( fVal );
return true;
}
@@ -3511,13 +3528,11 @@ bool ScCompiler::IsMacro( const OUString& rName )
#endif
}
-bool ScCompiler::IsNamedRange( const OUString& rUpperName )
+const ScRangeData* ScCompiler::GetRangeData( SCTAB& rSheet, const OUString& rUpperName ) const
{
- // IsNamedRange is called only from NextNewToken, with an upper-case string
-
// try local names first
- sal_Int16 nSheet = aPos.Tab();
- ScRangeName* pRangeName = rDoc.GetRangeName(nSheet);
+ rSheet = aPos.Tab();
+ const ScRangeName* pRangeName = rDoc.GetRangeName(rSheet);
const ScRangeData* pData = nullptr;
if (pRangeName)
pData = pRangeName->findByUpperName(rUpperName);
@@ -3527,9 +3542,17 @@ bool ScCompiler::IsNamedRange( const OUString& rUpperName )
if (pRangeName)
pData = pRangeName->findByUpperName(rUpperName);
if (pData)
- nSheet = -1;
+ rSheet = -1;
}
+ return pData;
+}
+
+bool ScCompiler::IsNamedRange( const OUString& rUpperName )
+{
+ // IsNamedRange is called only from NextNewToken, with an upper-case string
+ SCTAB nSheet = -1;
+ const ScRangeData* pData = GetRangeData( nSheet, rUpperName);
if (pData)
{
maRawToken.SetName( nSheet, pData->GetIndex());
@@ -3540,7 +3563,7 @@ bool ScCompiler::IsNamedRange( const OUString& rUpperName )
if (mnCurrentSheetEndPos > 0 && mnCurrentSheetTab >= 0)
{
OUString aName( rUpperName.copy( mnCurrentSheetEndPos));
- pRangeName = rDoc.GetRangeName( mnCurrentSheetTab);
+ const ScRangeName* pRangeName = rDoc.GetRangeName( mnCurrentSheetTab);
if (pRangeName)
{
pData = pRangeName->findByUpperName(aName);