forms/source/xforms/convert.cxx | 5 +++-- forms/source/xforms/datatypes.cxx | 30 +++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-)
New commits: commit 3b4982b9c702002072dc3a9f7755f820eada08e7 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Tue Apr 18 18:07:17 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Apr 19 08:03:55 2023 +0200 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.gran...@collabora.co.uk> 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 ) )