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 2005/07/19 06:33:47 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/dv/xs DayDV.java MonthDayDV.java MonthDV.java AbstractDateTimeDV.java
mrglavas 2005/07/18 21:33:45
Modified: java/src/org/apache/xerces/impl/dv/xs DayDV.java
MonthDayDV.java MonthDV.java
AbstractDateTimeDV.java
Log:
Fixing a bug affecting the following types: date, gDay, gMonthDay, gMonth and gYearMonth.
We were accepting garbage immediately before the time zone, so a value such as
"1111-11-11 some arbitrary text -05:00" was passing through without an error being flagged.
Revision Changes Path
1.18 +3 -4 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DayDV.java
Index: DayDV.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DayDV.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DayDV.java 6 May 2005 15:31:14 -0000 1.17
+++ DayDV.java 19 Jul 2005 04:32:12 -0000 1.18
@@ -68,12 +68,11 @@
date.day=parseInt(str, 3,5);
if ( DAY_SIZE<len ) {
- int sign = findUTCSign(str, DAY_SIZE, len);
- if ( sign<0 ) {
+ if (!isNextCharUTCSign(str, DAY_SIZE, len)) {
throw new SchemaDateTimeException ("Error in day parsing");
}
else {
- getTimeZone(str, date, sign, len);
+ getTimeZone(str, date, DAY_SIZE, len);
}
}
1.18 +3 -4 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java
Index: MonthDayDV.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- MonthDayDV.java 6 May 2005 15:31:14 -0000 1.17
+++ MonthDayDV.java 19 Jul 2005 04:32:24 -0000 1.18
@@ -80,12 +80,11 @@
date.day=parseInt(str, start, start+2);
if ( MONTHDAY_SIZE<len ) {
- int sign = findUTCSign(str, MONTHDAY_SIZE, len);
- if ( sign<0 ) {
+ if (!isNextCharUTCSign(str, MONTHDAY_SIZE, len)) {
throw new SchemaDateTimeException ("Error in month parsing:" +str);
}
else {
- getTimeZone(str, date, sign, len);
+ getTimeZone(str, date, MONTHDAY_SIZE, len);
}
}
//validate and normalize
1.20 +3 -4 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDV.java
Index: MonthDV.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDV.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- MonthDV.java 6 May 2005 15:31:14 -0000 1.19
+++ MonthDV.java 19 Jul 2005 04:32:30 -0000 1.20
@@ -78,12 +78,11 @@
stop += 2;
}
if (stop < len) {
- int sign = findUTCSign(str, stop, len);
- if ( sign<0 ) {
+ if (!isNextCharUTCSign(str, stop, len)) {
throw new SchemaDateTimeException ("Error in month parsing: "+str);
}
else {
- getTimeZone(str, date, sign, len);
+ getTimeZone(str, date, stop, len);
}
}
//validate and normalize
1.40 +15 -5 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
Index: AbstractDateTimeDV.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- AbstractDateTimeDV.java 6 May 2005 15:31:14 -0000 1.39
+++ AbstractDateTimeDV.java 19 Jul 2005 04:32:40 -0000 1.40
@@ -329,13 +329,12 @@
//fStart points right after the date
- if ( start<end ) {
- int sign = findUTCSign(buffer, start, end);
- if ( sign<0 ) {
+ if ( start < end ) {
+ if (!isNextCharUTCSign(buffer, start, end)) {
throw new RuntimeException ("Error in month parsing");
}
else {
- getTimeZone(buffer, date, sign, end);
+ getTimeZone(buffer, date, start, end);
}
}
}
@@ -493,6 +492,17 @@
}
return -1;
}
+
+ /**
+ * Returns <code>true</code> if the character at start is 'Z', '+' or '-'.
+ */
+ protected final boolean isNextCharUTCSign(String buffer, int start, int end) {
+ if (start < end) {
+ char c = buffer.charAt(start);
+ return (c == 'Z' || c == '+' || c == '-');
+ }
+ return false;
+ }
/**
* Given start and end position, parses string value
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org