You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2008/01/05 01:17:56 UTC
svn commit: r609062 - in /cocoon/branches/BRANCH_2_1_X: ./
src/java/org/apache/cocoon/components/sax/ src/test/org/apache/cocoon/xml/
Author: antonio
Date: Fri Jan 4 16:17:54 2008
New Revision: 609062
URL: http://svn.apache.org/viewvc?rev=609062&view=rev
Log:
<action dev="AG" type="fix" fixes-bug="COCOON-2158">
Core: XMLByteStreamCompiler hard-coded limits of 0xffff Strings prevents large XML documents
from being handled in Cocoon.
</action>
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/xml/AbstractXMLTestCase.java
cocoon/branches/BRANCH_2_1_X/status.xml
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java?rev=609062&r1=609061&r2=609062&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java Fri Jan 4 16:17:54 2008
@@ -212,14 +212,23 @@
map.put(str, new Integer(mapCount++));
int length = str.length();
this.writeChars(str.toCharArray(), 0, length);
- }
- else {
+ } else {
int i = index.intValue();
- if (i > 0xFFFF) throw new SAXException("Index too large");
-
- this.write(((i >>> 8) & 0xFF) | 0x80);
- this.write((i >>> 0) & 0xFF);
+ if (i <= 0x7FFF) {
+ // write index value in 16-bits
+ this.write(((i >>> 8) & 0xFF) | 0x80);
+ this.write((i >>> 0) & 0xFF);
+ } else {
+ // write escape code (Short.MAX_VALUE) to write a full 32-bit value
+ write((byte)0x7F);
+ write((byte)0xFF);
+ // write index value in 32-bit
+ write((byte) ((i >>> 24) & 0xFF) | 0x80);
+ write((byte) ((i >>> 16) & 0xFF));
+ write((byte) ((i >>> 8) & 0xFF));
+ write((byte) ((i >>> 0) & 0xFF));
+ }
}
}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java?rev=609062&r1=609061&r2=609062&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java Fri Jan 4 16:17:54 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -85,7 +85,7 @@
/**
* This method needs to be used by sub classes to start the parsing of the byte stream
- *
+ *
* @throws SAXException
*/
protected void parse() throws SAXException {
@@ -155,8 +155,8 @@
}
break;
case START_DTD:
- lexicalHandler.startDTD(this.readString(),
- this.readString(),
+ lexicalHandler.startDTD(this.readString(),
+ this.readString(),
this.readString());
break;
case END_DTD:
@@ -199,13 +199,19 @@
private String readString() throws SAXException {
int length = this.readWord();
- int index = length & 0x00007FFF;
+ int index;
if (length >= 0x00008000) {
+ // index value in 16-bits format
+ index = length & 0x00007FFF;
return (String) list.get(index);
- }
- else {
+ } else {
if (length == 0x00007FFF) {
length = this.readLong();
+ if (length >= 0x80000000) {
+ // index value in 32-bits format
+ index = length & 0x7fffffff;
+ return (String) list.get(index);
+ }
}
char[] chars = this.readChars(length);
int len = chars.length;
Modified: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/xml/AbstractXMLTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/xml/AbstractXMLTestCase.java?rev=609062&r1=609061&r2=609062&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/xml/AbstractXMLTestCase.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/xml/AbstractXMLTestCase.java Fri Jan 4 16:17:54 2008
@@ -55,8 +55,7 @@
consumer.startDocument();
consumer.startElement("", "root", "root", atts);
-// for (int i=0; i<0x1ffff; ++i) { // breaks current code
- for (int i=0; i<0x0ff0; ++i) { // doesn't break current code
+ for (int i=0; i<0x10000; ++i) {
final String uniqueString = "f_" + i;
consumer.startElement("", uniqueString, uniqueString, atts);
consumer.endElement("", uniqueString, uniqueString);
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=609062&r1=609061&r2=609062&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Fri Jan 4 16:17:54 2008
@@ -182,7 +182,10 @@
<changes>
<release version="2.1.12" date="TBD">
- <action dev="NN" type="fix">DUMMY</action>
+ <action dev="AG" type="fix" fixes-bug="COCOON-2158">
+ Core: XMLByteStreamCompiler hard-coded limits of 0xffff Strings prevents large XML documents
+ from being handled in Cocoon.
+ </action>
</release>
<release version="2.1.11" date="December 31 2007">
<action dev="RG" type="fix" fixes-bug="COCOON-1574">