You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/12/12 19:50:25 UTC
svn commit: r603701 -
/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/YearDV.java
Author: mrglavas
Date: Wed Dec 12 10:50:24 2007
New Revision: 603701
URL: http://svn.apache.org/viewvc?rev=603701&view=rev
Log:
Fixing JIRA Bug #1286:
http://issues.apache.org/jira/browse/XERCESJ-1286
YearDV was allowing xs:gYear values with fewer than four digits and also
lexical values with greater than four digits with a leading zero. We now
check for those conditions.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/YearDV.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/YearDV.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/YearDV.java?rev=603701&r1=603700&r2=603701&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/YearDV.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/YearDV.java Wed Dec 12 10:50:24 2007
@@ -68,6 +68,15 @@
start = 1;
}
int sign = findUTCSign(str, start, len);
+
+ final int length = ((sign == -1) ? len : sign) - start;
+ if (length < 4) {
+ throw new RuntimeException("Year must have 'CCYY' format");
+ }
+ else if (length > 4 && str.charAt(start) == '0') {
+ throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
+ }
+
if (sign == -1) {
date.year=parseIntYear(str, len);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org