You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Preston L. Bannister" <pr...@home.com> on 2000/01/09 11:57:50 UTC
[PATCH] to get Tomcat to build, and minor cleanup
Updated from CVS tonite. The result does not build.
Also spotted a couple typos...
The patch fixes the what's wrong and includes minor cleanup.
---
BTW, I would like to get commit access, rather than two step on stuff like this.
So who do I talk to?
(Yes, I read the Guidelines :).
---
Index: src/share/javax/servlet/http/HttpUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/javax/servlet/http/HttpUtils.java,v
retrieving revision 1.4
diff -u -b -r1.4 HttpUtils.java
--- HttpUtils.java 2000/01/08 21:31:38 1.4
+++ HttpUtils.java 2000/01/09 10:34:20
@@ -214,10 +214,6 @@
static public Hashtable parsePostData(int len,
ServletInputStream in)
{
- int inputLen, offset;
- byte[] postedBytes = null;
- String postedBody;
-
// XXX
// should a length of 0 be an IllegalArgumentException
@@ -228,34 +224,37 @@
throw new IllegalArgumentException();
}
- try {
//
// Make sure we read the entire POSTed body.
//
- postedBytes = new byte [len];
- offset = 0;
+ byte[] postedBytes = new byte [len];
+ try {
+ int offset = 0;
do {
- inputLen = in.read (postedBytes, offset, len - offset);
+ int inputLen = in.read (postedBytes, offset, len - offset);
if (inputLen <= 0) {
String msg = lStrings.getString("err.io.short_read");
- throw new IOException (msg);
+ throw new IllegalArgumentException(msg);
}
offset += inputLen;
} while ((len - offset) > 0);
-
} catch (IOException e) {
- return nullHashtable;
+ throw new IllegalArgumentException(e.getMessage());
}
+ // XXX we shouldn't assume that the only kind of POST body
+ // is FORM data encoded using ASCII or ISO Latin/1 ... or
+ // that the body should always be treated as FORM data.
+ //
+
try {
- postedBody = new String(postedBytes, 0, len, "8859_1");
+ String postedBody = new String(postedBytes, 0, len, "8859_1");
+ return parseQueryString(postedBody);
} catch (java.io.UnsupportedEncodingException e) {
// XXX function should accept an encoding parameter & throw this
// exception. Otherwise throw something expected.
throw new IllegalArgumentException(e.getMessage());
}
-
- return parseQueryString(postedBody);
}
Index: src/share/org/apache/jasper/compiler/JspReader.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
retrieving revision 1.9
diff -u -b -r1.9 JspReader.java
--- JspReader.java 2000/01/08 21:31:38 1.9
+++ JspReader.java 2000/01/09 10:34:21
@@ -117,17 +117,19 @@
public void pushFile(String name, String encoding)
throws ParseException, FileNotFoundException
{
- String parent = master == null ?
- null : master.substring(0, master.lastIndexOf("/") + 1);
- boolean isAbsolute = name.startsWith("/");
-
- if (parent == null || isAbsolute)
- pushFile(new File(name), encoding);
- else
- pushFile(new File(parent + name), encoding);
+ //System.out.println("pushFile master = " + master + ", name = " + name + ", encoding = " + encoding);
- if (master == null)
+ if (null == master) {
master = name;
+ pushFile(new File(name),encoding);
+ return;
+ }
+ if (name.startsWith("/")) {
+ pushFile(new File(name),encoding);
+ return;
+ }
+ String parent = master.substring(0, master.lastIndexOf("/") + 1);
+ pushFile(new File(parent,name),encoding);
}
/**
Index: src/share/org/apache/tomcat/util/MessageBytes.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 MessageBytes.java
--- MessageBytes.java 1999/10/09 00:20:56 1.1.1.1
+++ MessageBytes.java 2000/01/09 10:34:23
@@ -173,8 +173,15 @@
* Returns the message bytes as a String object.
*/
public String toString() {
- return bytes != null ? new String(bytes, offset, length) : null;
+ if (null == bytes) {
+ return null;
}
+ try {
+ return new String(bytes, offset, length, Constants.CharacterEncoding.Default);
+ } catch (java.io.UnsupportedEncodingException e) {
+ return null; // could return something - but why?
+ }
+ }
/**
* Returns the message bytes parsed as an unsigned integer.
Index: src/tests/share/tests/perf/CounterClient.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/tests/share/tests/perf/CounterClient.java,v
retrieving revision 1.3
diff -u -b -r1.3 CounterClient.java
--- CounterClient.java 2000/01/08 21:31:42 1.3
+++ CounterClient.java 2000/01/09 10:34:24
@@ -183,7 +183,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,"UTF8").trim());
} catch (IOException ioe) {
if (this.Debug) {
ioe.printStackTrace();
Index: src/tests/webpages/WEB-INF/classes/Counter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/tests/webpages/WEB-INF/classes/Counter.java,v
retrieving revision 1.2
diff -u -b -r1.2 Counter.java
--- Counter.java 2000/01/08 21:31:43 1.2
+++ Counter.java 2000/01/09 10:34:25
@@ -67,7 +67,7 @@
res.setContentType(mimeType);
ServletOutputStream out = res.getOutputStream();
- byte[] b = Integer.toString(count).getBytes("UTF");
+ byte[] b = Integer.toString(count).getBytes("UTF8");
try {
out.write(b);
Process completed with exit code 1
RE: [PATCH] to get Tomcat to build, and minor cleanup
Posted by "Preston L. Bannister" <pr...@home.com>.
From: costin@eng.sun.com
> -1 on changes to javax.* without consulting the spec side !
> ( I like the change and it's good from my point of view,
> but as a rule changes in javax shouldn't be done as easy !)
I agree with this BTW :).
What Costin is pointing out is the change to:
javax.servlet.http.HttpUtils.parsePostData()
where it now throws an exception on a short read.
My first pass changed the function signature to throw an
IOException - which is probably more appropriate but changes
a bit of the javax.* API.
I saw on the second pass (review before commit) this was part of
the public Servlet API, checked the spec (did I miss something?),
and changed this to an IllegalArgumentException.
The original code returned a non-error result on a short read.
So hopefully we are not in actual disagreement here :).
Re: [PATCH] to get Tomcat to build, and minor cleanup
Posted by co...@eng.sun.com.
"Preston L. Bannister" wrote:
> Updated from CVS tonite. The result does not build.
> Also spotted a couple typos...
>
> The patch fixes the what's wrong and includes minor cleanup.
>
> ---
>
> BTW, I would like to get commit access, rather than two step on stuff like this.
+1 on that.
-1 on changes to javax.* without consulting the spec side !
( I like the change and it's good from my point of view,
but as a rule changes in javax shouldn't be done as easy !)
Costin