You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/05/13 14:16:53 UTC
[tomcat] branch master updated: Ensure context default request
encoding applies to getReader()
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new b0a743e Ensure context default request encoding applies to getReader()
b0a743e is described below
commit b0a743e9ad6ba54f0ab91d0765b2003362ecd656
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon May 13 15:16:07 2019 +0100
Ensure context default request encoding applies to getReader()
---
java/org/apache/catalina/connector/Request.java | 20 +++++++++++++++++++-
webapps/docs/changelog.xml | 5 +++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index db51182..dbcd799 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1212,13 +1212,31 @@ public class Request implements HttpServletRequest {
(sm.getString("coyoteRequest.getReader.ise"));
}
+ // InputBuffer has no easily accessible reference chain to the Context
+ // to check for a default request character encoding at the Context.
+ // Therefore, if a Context default should be used, it is set explicitly
+ // here. Need to do this before setting usingReader.
+ if (coyoteRequest.getCharacterEncoding() == null) {
+ // Nothing currently set explicitly.
+ // Check the content
+ Context context = getContext();
+ if (context != null) {
+ String enc = context.getRequestCharacterEncoding();
+ if (enc != null) {
+ // Explicitly set the context default so it is visible to
+ // InputBuffer when creating the Reader.
+ setCharacterEncoding(enc);
+ }
+ }
+ }
+
usingReader = true;
+
inputBuffer.checkConverter();
if (reader == null) {
reader = new CoyoteReader(inputBuffer);
}
return reader;
-
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f81c36e..f34c849 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -54,6 +54,11 @@
Fix <code>--no-jmx</code> flag processing, which was called after
registry initialization. (remm)
</fix>
+ <fix>
+ Ensure that a default request character encoding set on a
+ <code>ServletContext</code> is used when calling
+ <code>ServletRequest#getReader()</code>. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org