Sfoglia il codice sorgente

Internal: improved the API robustness by throwing an exception as soon as DBObject::Set is called with a date badly formatted. This is in line with the assumption that internal DBObject values are always safe.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4435 a333f486-631f-4898-b8df-5754b55c2be0
romainq 8 anni fa
parent
commit
ebba62606c
1 ha cambiato i file con 11 aggiunte e 0 eliminazioni
  1. 11 0
      core/attributedef.class.inc.php

+ 11 - 0
core/attributedef.class.inc.php

@@ -3811,6 +3811,17 @@ class AttributeDateTime extends AttributeDBField
 		}
 		if (!is_numeric($proposedValue))
 		{
+			// Check the format
+			try
+			{
+				$oFormat = new DateTimeFormat($this->GetInternalFormat());
+				$oTrash = $oFormat->Parse($proposedValue);
+			}
+			catch (Exception $e)
+			{
+				throw new Exception('Wrong format for date attribute '.$this->GetCode().', expecting "'.$this->GetInternalFormat().'" and got "'.$proposedValue.'"');
+			}
+
 			return $proposedValue;
 		}