You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2003/10/13 00:34:03 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers DecodeInterceptor.java
billbarker 2003/10/12 15:34:03
Modified: src/share/org/apache/tomcat/core Response.java
src/share/org/apache/tomcat/modules/mappers
DecodeInterceptor.java
Log:
Make certain that only explictly set charsets are remembered for the "guess charset" feature.
The problem is that static content will reset the charset back to iso-latin-1 before the form is posted.
Fix for bug #11933
Reported By: Uri uri@ntr.co.il
Revision Changes Path
1.57 +11 -1 jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
Index: Response.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- Response.java 3 Jun 2002 17:25:00 -0000 1.56
+++ Response.java 12 Oct 2003 22:34:02 -0000 1.57
@@ -117,6 +117,7 @@
protected String contentType = DEFAULT_CONTENT_TYPE;
protected String contentLanguage = null;
protected String characterEncoding = DEFAULT_CHAR_ENCODING;
+ protected boolean haveCharacterEncoding = false;
protected Locale locale = DEFAULT_LOCALE;
// -------------------- Constructor --------------------
@@ -251,6 +252,7 @@
contentType = DEFAULT_CONTENT_TYPE;
locale = DEFAULT_LOCALE;
characterEncoding = DEFAULT_CHAR_ENCODING;
+ haveCharacterEncoding = false;
status = 200;
headers.clear();
}
@@ -443,8 +445,14 @@
headers.setValue("Content-Language").setString( contentLanguage);
}
+ public String getCharacterEncoding(boolean defaultOK) {
+ if(defaultOK || haveCharacterEncoding)
+ return characterEncoding;
+ return null;
+ }
+
public String getCharacterEncoding() {
- return characterEncoding;
+ return getCharacterEncoding(true);
}
public void setContentType(String contentType) {
@@ -453,6 +461,7 @@
String encoding = ContentType.getCharsetFromContentType(contentType);
if (encoding != null) {
characterEncoding = encoding;
+ haveCharacterEncoding = true;
}
headers.setValue("Content-Type").setString( contentType);
}
@@ -503,6 +512,7 @@
contentLanguage = null;
locale = DEFAULT_LOCALE;
characterEncoding = DEFAULT_CHAR_ENCODING;
+ haveCharacterEncoding = false;
status = 200;
usingWriter = false;
usingStream = false;
1.22 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/DecodeInterceptor.java
Index: DecodeInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/DecodeInterceptor.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- DecodeInterceptor.java 22 Sep 2003 09:18:38 -0000 1.21
+++ DecodeInterceptor.java 12 Oct 2003 22:34:03 -0000 1.22
@@ -593,7 +593,7 @@
if( useSessionEncoding ) {
ServerSession sess=req.getSession( false );
if( sess!=null ) {
- String charset=res.getCharacterEncoding();
+ String charset=res.getCharacterEncoding(false);
if( charset!=null ) {
sess.setNote( sessionEncodingNote, charset );
if( debug > 0 )
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org