Commit ced21dfd authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed parsing errors. JM-1003 and JM-991

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/branches/3_2_branch@7788 b35dd754-fafc-0310-a699-88a17e54d16e
parent 478a7872
...@@ -54,6 +54,10 @@ class XMLLightweightParser { ...@@ -54,6 +54,10 @@ class XMLLightweightParser {
protected static final int INSIDE_PARAM_VALUE = 7; protected static final int INSIDE_PARAM_VALUE = 7;
// Status used when you are inside a cdata section // Status used when you are inside a cdata section
protected static final int INSIDE_CDATA = 8; protected static final int INSIDE_CDATA = 8;
// Status used when you are outside a tag/reading text
protected static final int OUTSIDE = 9;
final String[] sstatus = {"INIT", "", "HEAD", "INSIDE", "PRETAIL", "TAIL", "VERIFY", "INSIDE_PARAM", "INSIDE_CDATA", "OUTSIDE"};
// Current robot status // Current robot status
...@@ -133,6 +137,7 @@ class XMLLightweightParser { ...@@ -133,6 +137,7 @@ class XMLLightweightParser {
head.setLength(0); head.setLength(0);
insideRootTag = false; insideRootTag = false;
insideChildrenTag = false; insideChildrenTag = false;
depth = 0;
} }
/* /*
...@@ -154,7 +159,6 @@ class XMLLightweightParser { ...@@ -154,7 +159,6 @@ class XMLLightweightParser {
// Robot. // Robot.
char ch; char ch;
for (int i = 0; i < readByte; i++) { for (int i = 0; i < readByte; i++) {
//ch = rawByteBuffer[ i ];
ch = buf[i]; ch = buf[i];
if (status == XMLLightweightParser.TAIL) { if (status == XMLLightweightParser.TAIL) {
// Looking for the close tag // Looking for the close tag
...@@ -199,6 +203,7 @@ class XMLLightweightParser { ...@@ -199,6 +203,7 @@ class XMLLightweightParser {
} else if (status == XMLLightweightParser.VERIFY_CLOSE_TAG) { } else if (status == XMLLightweightParser.VERIFY_CLOSE_TAG) {
if (ch == '>') { if (ch == '>') {
depth--; depth--;
status = XMLLightweightParser.OUTSIDE;
if (depth < 1) { if (depth < 1) {
// Found a tag in the form <tag /> // Found a tag in the form <tag />
int end = buffer.length() - readByte + (i + 1); int end = buffer.length() - readByte + (i + 1);
...@@ -222,7 +227,7 @@ class XMLLightweightParser { ...@@ -222,7 +227,7 @@ class XMLLightweightParser {
if (ch == XMLLightweightParser.CDATA_END[cdataOffset]) { if (ch == XMLLightweightParser.CDATA_END[cdataOffset]) {
cdataOffset++; cdataOffset++;
if (cdataOffset == XMLLightweightParser.CDATA_END.length) { if (cdataOffset == XMLLightweightParser.CDATA_END.length) {
status = XMLLightweightParser.INSIDE; status = XMLLightweightParser.OUTSIDE;
cdataOffset = 0; cdataOffset = 0;
} }
} else { } else {
...@@ -238,10 +243,12 @@ class XMLLightweightParser { ...@@ -238,10 +243,12 @@ class XMLLightweightParser {
} }
} else { } else {
cdataOffset = 0; cdataOffset = 0;
status = XMLLightweightParser.INSIDE;
} }
if (ch == '"') { if (ch == '"') {
status = XMLLightweightParser.INSIDE_PARAM_VALUE; status = XMLLightweightParser.INSIDE_PARAM_VALUE;
} else if (ch == '>') { } else if (ch == '>') {
status = XMLLightweightParser.OUTSIDE;
if (insideRootTag && ("stream:stream>".equals(head.toString()) || if (insideRootTag && ("stream:stream>".equals(head.toString()) ||
("?xml>".equals(head.toString())) || ("flash:stream>".equals(head.toString())))) { ("?xml>".equals(head.toString())) || ("flash:stream>".equals(head.toString())))) {
// Found closing stream:stream // Found closing stream:stream
...@@ -255,16 +262,16 @@ class XMLLightweightParser { ...@@ -255,16 +262,16 @@ class XMLLightweightParser {
startLastMsg = end; startLastMsg = end;
} }
insideRootTag = false; insideRootTag = false;
} else if (ch == '<') {
status = XMLLightweightParser.PRETAIL;
insideChildrenTag = true;
} else if (ch == '/') { } else if (ch == '/') {
status = XMLLightweightParser.VERIFY_CLOSE_TAG; status = XMLLightweightParser.VERIFY_CLOSE_TAG;
} }
} else if (status == XMLLightweightParser.HEAD) { } else if (status == XMLLightweightParser.HEAD) {
if (ch == ' ' || ch == '>') { if (ch == ' ' || ch == '>') {
// Append > to head to facility the research of </tag> // Append > to head to allow searching </tag>
head.append(">"); head.append(">");
if(ch == '>')
status = XMLLightweightParser.OUTSIDE;
else
status = XMLLightweightParser.INSIDE; status = XMLLightweightParser.INSIDE;
insideRootTag = true; insideRootTag = true;
insideChildrenTag = false; insideChildrenTag = false;
...@@ -284,6 +291,12 @@ class XMLLightweightParser { ...@@ -284,6 +291,12 @@ class XMLLightweightParser {
else { else {
startLastMsg++; startLastMsg++;
} }
} else if (status == XMLLightweightParser.OUTSIDE) {
if (ch == '<') {
status = XMLLightweightParser.PRETAIL;
cdataOffset = 1;
insideChildrenTag = true;
}
} }
} }
if (head.length() > 0 && if (head.length() > 0 &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment