You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2021/04/20 21:51:05 UTC
[tomee] branch master updated: Half backport missing
This is an automated email from the ASF dual-hosted git repository.
jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/master by this push:
new 2d78406 Half backport missing
2d78406 is described below
commit 2d78406222148fea0428c57df2cac5d6c0ce6ea1
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Tue Apr 20 23:50:51 2021 +0200
Half backport missing
---
tomee/apache-tomee/pom.xml | 8 ++++++
.../apache/catalina/servlets/DefaultServlet.java | 30 +++++++++++++++++-----
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/tomee/apache-tomee/pom.xml b/tomee/apache-tomee/pom.xml
index 9863409..86034dd 100644
--- a/tomee/apache-tomee/pom.xml
+++ b/tomee/apache-tomee/pom.xml
@@ -129,6 +129,14 @@
<version>${project.version}</version>
<type>jar</type>
</dependency>
+
+ <!-- needed to compile in intellij for tomcat patches -->
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina</artifactId>
+ <version>${tomcat.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/catalina/servlets/DefaultServlet.java b/tomee/apache-tomee/src/patch/java/org/apache/catalina/servlets/DefaultServlet.java
index 160cefd..7b3c0b7 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/tomee/apache-tomee/src/patch/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -246,8 +246,17 @@ public class DefaultServlet extends HttpServlet {
/**
* If a file has a BOM, should that be used in preference to fileEncoding?
+ *
+ * - true - BoM is stripped if present and any BoM found used to determine
+ * the encoding used to read the resource. This is the default.
+ *
+ * - false - BoM is stripped and resource is read using the configured file
+ * encoding (which will be the platform default if not explicitly
+ * configured)
+ *
+ * - path-through - as current false but does not strip the BoM from the output
*/
- private boolean useBomIfPresent = true;
+ private String useBomIfPresent = "true";
/**
* Minimum size for sendfile usage in bytes.
@@ -335,8 +344,15 @@ public class DefaultServlet extends HttpServlet {
}
}
- if (getServletConfig().getInitParameter("useBomIfPresent") != null) {
- useBomIfPresent = Boolean.parseBoolean(getServletConfig().getInitParameter("useBomIfPresent"));
+ final String useBomIfPresentConfig = getServletConfig().getInitParameter("useBomIfPresent");
+ if (useBomIfPresentConfig != null) {
+ if (!Arrays.asList("true", "false", "pass-through").contains(useBomIfPresentConfig)) {
+ if (debug > 0) {
+ log("DefaultServlet.init: unsupported value " + useBomIfPresentConfig + " for useBomIfPresent." +
+ " One of 'true', 'false', 'pass-through' is expected. Using 'true' by default.");
+ }
+ }
+ useBomIfPresent = useBomIfPresentConfig;
}
globalXsltFile = getServletConfig().getInitParameter("globalXsltFile");
@@ -1083,8 +1099,8 @@ public class DefaultServlet extends HttpServlet {
if (!renderResult.markSupported()) {
renderResult = new BufferedInputStream(renderResult);
}
- Charset bomCharset = processBom(renderResult);
- if (bomCharset != null && useBomIfPresent) {
+ Charset bomCharset = processBom(renderResult, isStripBOM());
+ if (bomCharset != null && "true".equals(useBomIfPresent)) {
inputEncoding = bomCharset.name();
}
}
@@ -1105,8 +1121,8 @@ public class DefaultServlet extends HttpServlet {
if (!source.markSupported()) {
source = new BufferedInputStream(source);
}
- Charset bomCharset = processBom(source);
- if (bomCharset != null && useBomIfPresent) {
+ Charset bomCharset = processBom(source, isStripBOM());
+ if (bomCharset != null && "true".equals(useBomIfPresent)) {
inputEncoding = bomCharset.name();
}
// Following test also ensures included resources