1 package com.atlassian.core.filters.encoding;
2
3 import org.apache.commons.lang.StringUtils;
4
5 import javax.servlet.http.HttpServletResponse;
6 import javax.servlet.http.HttpServletResponseWrapper;
7
8
9
10
11
12
13
14
15
16
17
18 public final class FixedHtmlEncodingResponseWrapper extends HttpServletResponseWrapper
19 {
20 public FixedHtmlEncodingResponseWrapper(HttpServletResponse response)
21 {
22 super(response);
23 }
24
25 public final void setContentType(String contentType)
26 {
27
28
29 if (StringUtils.startsWith(contentType, "text/html") && contentType.length() > "text/html".length())
30 {
31 return;
32 }
33
34
35
36 if (StringUtils.trimToEmpty(contentType).equals("text/html"))
37 {
38 super.setContentType(contentType + ";charset=" + getResponse().getCharacterEncoding());
39 return;
40 }
41
42
43 super.setContentType(contentType);
44 }
45 }