summaryrefslogtreecommitdiff
path: root/forms/source
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2023-04-18 18:07:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-19 08:03:55 +0200
commit3b4982b9c702002072dc3a9f7755f820eada08e7 (patch)
tree4c675879d3c3a5be1319c1cbee9e082422413cca /forms/source
parent4396c1a2294d6904b5aa808a1f970a2586d63962 (diff)
Related tdf#154769: XML form, detect misformed date/datetime/time
Change-Id: Ied859703f906ef97c70be4518974ca6a0e482573 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150582 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms/source')
-rw-r--r--forms/source/xforms/convert.cxx5
-rw-r--r--forms/source/xforms/datatypes.cxx30
2 files changed, 30 insertions, 5 deletions
diff --git a/forms/source/xforms/convert.cxx b/forms/source/xforms/convert.cxx
index 5cd017ac0c5a..8ffd4cab4906 100644
--- a/forms/source/xforms/convert.cxx
+++ b/forms/source/xforms/convert.cxx
@@ -25,6 +25,7 @@
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
#include <tools/date.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/uno/Type.hxx>
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/DateTime.hpp>
@@ -133,7 +134,7 @@ namespace
// all okay?
if ( !bWellformed )
- return css::util::Date( 1, 1, 1900 );
+ throw com::sun::star::lang::IllegalArgumentException();
return aDate;
}
@@ -203,7 +204,7 @@ namespace
// all okay?
if ( !bWellformed )
- return css::util::Time();
+ throw com::sun::star::lang::IllegalArgumentException();
return aTime;
}
diff --git a/forms/source/xforms/datatypes.cxx b/forms/source/xforms/datatypes.cxx
index c372298f0e5f..ea71dc85af83 100644
--- a/forms/source/xforms/datatypes.cxx
+++ b/forms/source/xforms/datatypes.cxx
@@ -730,7 +730,15 @@ namespace xforms
bool ODateType::_getValue( const OUString& value, double& fValue )
{
- Any aTypeValue = Convert::get().toAny( value, getCppuType() );
+ Any aTypeValue;
+ try
+ {
+ aTypeValue = Convert::get().toAny( value, getCppuType() );
+ }
+ catch (com::sun::star::lang::IllegalArgumentException)
+ {
+ return false;
+ }
Date aValue;
if ( !( aTypeValue >>= aValue ) )
@@ -779,7 +787,15 @@ namespace xforms
bool OTimeType::_getValue( const OUString& value, double& fValue )
{
- Any aTypedValue = Convert::get().toAny( value, getCppuType() );
+ Any aTypedValue;
+ try
+ {
+ aTypedValue = Convert::get().toAny( value, getCppuType() );
+ }
+ catch (com::sun::star::lang::IllegalArgumentException)
+ {
+ return false;
+ }
css::util::Time aValue;
if ( !( aTypedValue >>= aValue ) )
@@ -851,7 +867,15 @@ namespace xforms
bool ODateTimeType::_getValue( const OUString& value, double& fValue )
{
- Any aTypedValue = Convert::get().toAny( value, getCppuType() );
+ Any aTypedValue;
+ try
+ {
+ aTypedValue = Convert::get().toAny( value, getCppuType() );
+ }
+ catch (com::sun::star::uno::RuntimeException)
+ {
+ return false;
+ }
DateTime aValue;
if ( !( aTypedValue >>= aValue ) )