You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2001/11/16 16:56:37 UTC
cvs commit: xml-xerces/c/src/util/regx RegxParser.cpp
knoaman 01/11/16 07:56:37
Modified: c/src/util/regx RegxParser.cpp
Log:
Add check for invalid repeating quantifier.
Revision Changes Path
1.9 +18 -12 xml-xerces/c/src/util/regx/RegxParser.cpp
Index: RegxParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/util/regx/RegxParser.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- RegxParser.cpp 2001/09/20 13:11:42 1.8
+++ RegxParser.cpp 2001/11/16 15:56:37 1.9
@@ -56,6 +56,9 @@
/*
* $Log: RegxParser.cpp,v $
+ * Revision 1.9 2001/11/16 15:56:37 knoaman
+ * Add check for invalid repeating quantifier.
+ *
* Revision 1.8 2001/09/20 13:11:42 knoaman
* Regx + misc. fixes
*
@@ -876,6 +879,7 @@
int offset = fOffset;
int min = 0;
int max = -1;
+ bool minExist = false;
if (offset >= fStringLen)
break;
@@ -883,10 +887,10 @@
XMLInt32 ch = fString[offset++];
if (ch != chComma && (ch < chDigit_0 || ch > chDigit_9))
- break;
+ ThrowXML1(ParseException, XMLExcepts::Regex_InvalidQuantifier, fString);
if (ch != chComma) {
-
+ minExist = true;
min = ch - chDigit_0;
while (offset < fStringLen
&& (ch = fString[offset++]) >= chDigit_0
@@ -895,12 +899,14 @@
min = min*10 + ch - chDigit_0;
ch = -1;
}
-
- if (ch < 0)
- break;
}
max = min;
+
+ if (ch != chCloseCurly && ch != chComma) {
+ ThrowXML1(ParseException, XMLExcepts::Regex_InvalidQuantifier, fString);
+ }
+
if (ch == chComma) {
if (offset >= fStringLen
@@ -909,10 +915,12 @@
break;
if (ch == chCloseCurly) {
- max = -1;
+ if (minExist)
+ max = -1;
+ else
+ ThrowXML1(ParseException, XMLExcepts::Regex_InvalidQuantifier, fString);
}
else {
-
max = ch - chDigit_0;
while (offset < fStringLen
&& (ch = fString[offset++]) >= chDigit_0
@@ -922,13 +930,11 @@
ch = -1;
}
- if (ch < 0)
- break;
+ if (ch != chCloseCurly) {
+ ThrowXML1(ParseException, XMLExcepts::Regex_InvalidQuantifier, fString);
+ }
}
} // end if ch = chComma
-
- if (ch != chCloseCurly)
- break;
if (checkQuestion(offset)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org