Apache Lucene open-source search software
SOLR-214 - use the charset encoded in the contentType to decode the posted text. Even though they are supposed to, some containers do not obey this specification.
Ryan McKinleyc3df2607b0ac
diff --git a/CHANGES.txt b/CHANGES.txtindex bcb0ffa26a6..d92ad600957 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -271,6 +271,13 @@ Bug Fixes13. Changed the SOLR-104 RequestDispatcher so that /select?qt=xxx can notaccess handlers that start with "/". This makes path based authenticationpossible for path based request handlers. (ryan)++14. SOLR-214: Some servlet containers (including Tomcat and Resin) do not+ obey the specified charset. Rather then letting the the container handle+ it solr now uses the charset from the header contentType to decode posted+ content. Using the contentType: "text/xml; charset=utf-8" will force+ utf-8 encoding. If you do not specify a contentType, it will use the+ platform default. (Koji Sekiguchi via ryan)Other Changes1. Updated to Lucene 2.1diff --git a/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java b/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.javaindex 25d7816c50f..3615aa43a8c 100644--- a/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java+++ b/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java@@ -20,7 +20,6 @@ package org.apache.solr.servlet;import java.io.File;import java.io.IOException;import java.io.InputStream;-import java.io.Reader;import java.io.UnsupportedEncodingException;import java.net.URL;import java.net.URLDecoder;@@ -225,16 +224,27 @@ class RawRequestParser implements SolrRequestParserpublic SolrParams parseParamsAndFillStreams(final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception{- streams.add( new ContentStream() {+ // The javadocs for HttpServletRequest are clear that req.getReader() should take+ // care of any character encoding issues. BUT, there are problems while running on+ // some servlet containers: including Tomcat 5 and resin.+ //+ // Rather than return req.getReader(), this uses the default ContentStreamBase method+ // that checks for charset definitions in the ContentType.++ streams.add( new ContentStreamBase() {+ @Overridepublic String getContentType() {return req.getContentType();}+ @Overridepublic String getName() {- return null; // Is there any meaningfull name?+ return null; // Is there any meaningful name?}+ @Overridepublic String getSourceInfo() {- return null; // Is there any meaningfull name?+ return null; // Is there any meaningful source?}+ @Overridepublic Long getSize() {String v = req.getHeader( "Content-Length" );if( v != null ) {@@ -245,9 +255,6 @@ class RawRequestParser implements SolrRequestParserpublic InputStream getStream() throws IOException {return req.getInputStream();}- public Reader getReader() throws IOException {- return req.getReader();- }});return SolrRequestParsers.parseQueryString( req.getQueryString() );}