Committed. Khaled, Could you update Bugzilla? Thx.
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
[EMAIL PROTECTED]
XML - Khaled
Noaman/Toronto/IB To: [EMAIL PROTECTED]
[EMAIL PROTECTED] cc:
Subject: Patch for bug 17417
03/24/2003 01:31
PM
Please respond to
xerces-j-dev
Please find enclosed a patch for bug 17417.
Regards,
Khaled
--- D:
\cvswork\xml-xerces\java\src\org\apache\xerces\impl\xpath\regex\message.properties
2003-03-07 16:37:08.000000000 -0500
+++ message.properties 2003-03-18 10:12:39.000000000 -0500
@@ -30,3 +30,7 @@
parser.descape.4=Invalid Unicode code point.
parser.descape.5=An anchor must not be here.
parser.process.1=This expression is not supported in the current option
setting.
+parser.quantifier.1=Invalid quantifier. A digit is expected.
+parser.quantifier.2=Invalid quantifier. Invalid quantity or a '}' is
missing.
+parser.quantifier.3=Invalid quantifier. A digit or '}' is expexted.
+parser.quantifier.4=Invalid quantifier. A min quantity must be <= a max
quantity.
\ No newline at end of file
--- D:
\cvswork\xml-xerces\java\src\org\apache\xerces\impl\xpath\regex\RegexParser.java
2003-03-17 11:11:03.000000000 -0500
+++ RegexParser.java 2003-03-18 10:19:58.000000000 -0500
@@ -642,53 +642,57 @@
case T_PLUS: return this.processPlus(tok);
case T_QUESTION: return this.processQuestion(tok);
case T_CHAR:
- if (this.chardata == '{') {
- // this.offset -> next of
'{'
- int off = this.offset;
+ if (this.chardata == '{' && this.offset < this.regexlen) {
+
+ int off = this.offset; // this.offset -> next of
'{'
int min = 0, max = -1;
- if (off >= this.regexlen) break;
- ch = this.regex.charAt(off++);
- if (ch != ',' && (ch < '0' || ch > '9')) break;
- if (ch != ',') { // 0-9
- min = ch-'0';
+
+ if ((ch = this.regex.charAt(off++)) >= '0' && ch <= '9') {
+
+ min = ch -'0';
while (off < this.regexlen
&& (ch = this.regex.charAt(off++)) >= '0' && ch
<= '9') {
min = min*10 +ch-'0';
- ch = -1;
}
- if (ch < 0) break;
}
- //if (off >= this.regexlen) break;
+ else {
+ throw ex("parser.quantifier.1", this.offset);
+ }
+
max = min;
if (ch == ',') {
- if (off >= this.regexlen
- || ((ch = this.regex.charAt(off++)) < '0' || ch >
'9')
- && ch != '}')
- break;
- if (ch == '}') {
- max = -1; // {min,}
- } else {
- max = ch-'0'; // {min,max}
+
+ if (off >= this.regexlen) {
+ throw ex("parser.quantifier.3", this.offset);
+ }
+ else if ((ch = this.regex.charAt(off++)) >= '0' && ch
<= '9') {
+
+ max = ch -'0'; // {min,max}
while (off < this.regexlen
&& (ch = this.regex.charAt(off++)) >= '0'
&& ch <= '9') {
max = max*10 +ch-'0';
- ch = -1;
}
- if (ch < 0) break;
- //if (min > max)
- // throw new ParseException("parseFactor(): min
> max: "+min+", "+max);
+
+ if (min > max)
+ throw ex("parser.quantifier.4", this.offset);
+ }
+ else { // assume {min,}
+ max = -1;
}
}
- if (ch != '}') break;
- // off -> next of '}'
- if (this.checkQuestion(off)) {
+
+ if (ch != '}')
+ throw ex("parser.quantifier.2", this.offset);
+
+ if (this.checkQuestion(off)) { // off -> next of '}'
tok = Token.createNGClosure(tok);
this.offset = off+1;
} else {
tok = Token.createClosure(tok);
this.offset = off;
}
+
tok.setMin(min);
tok.setMax(max);
//System.err.println("CLOSURE: "+min+", "+max);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]