[utilities COMMIT] /java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java

noreply at shibboleth.net noreply at shibboleth.net
Sat Jan 14 15:37:10 GMT 2012


Author: rdw
Date: Sat Jan 14 15:37:10 2012
New Revision: 201

URL: http://svn.shibboleth.net/view/utilities?rev=201&view=rev
Log:
Further protect GetDateTime and GetDuration from malformed input

Modified:
    java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java

Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java?rev=201&r1=200&r2=201&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java Sat Jan 14 15:37:10 2012
@@ -351,7 +351,7 @@
      * @return date/time in millisecond since the epoch, or null if the attribute was null
      */
     @Nullable public static Long getDateTimeAttributeAsLong(@Nullable final Attr attribute) {
-        if (attribute == null) {
+        if (attribute == null || StringSupport.trimOrNull(attribute.getValue()) == null) {
             return null;
         }
 
@@ -366,7 +366,7 @@
      * @return duration, in millisecond, or null if the attribute was null
      */
     @Nullable public static Long getDurationAttributeValueAsLong(@Nullable final Attr attribute) {
-        if (attribute == null) {
+        if (attribute == null || StringSupport.trimOrNull(attribute.getValue()) == null)  {
             return null;
         }
 
@@ -470,10 +470,9 @@
         if (null == value) {
             return null;
         }
-        try { 
+        try {
             return XmlSpace.parseValue(value);
-        }
-        catch (IllegalArgumentException e) {
+        } catch (IllegalArgumentException e) {
             // No match to the type
             return null;
         }



More information about the commits mailing list