Skip to content

Instantly share code, notes, and snippets.

@nuzayats
Created December 29, 2014 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuzayats/fb47df1945e06739c1f2 to your computer and use it in GitHub Desktop.
Save nuzayats/fb47df1945e06739c1f2 to your computer and use it in GitHub Desktop.
Patch for ROL-2057
Index: app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java (revision )
+++ app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java (revision )
@@ -420,13 +420,19 @@
if (StringUtils.isNotEmpty(page.getOutputContentType())) {
contentType = page.getOutputContentType() + "; charset=utf-8";
} else {
+ final String defaultContentType = "text/html; charset=utf-8";
+ // prevent NPE at ServletContext#getMimeType(null) on some implementations
+ if (page.getLink() == null) {
+ contentType = defaultContentType;
+ } else {
- String mimeType = RollerContext.getServletContext().getMimeType(
- page.getLink());
- if (mimeType != null) {
- // we found a match ... set the content deviceType
- contentType = mimeType + "; charset=utf-8";
- } else {
+ String mimeType = RollerContext.getServletContext().getMimeType(
+ page.getLink());
+ if (mimeType != null) {
+ // we found a match ... set the content deviceType
+ contentType = mimeType + "; charset=utf-8";
+ } else {
- contentType = "text/html; charset=utf-8";
+ contentType = defaultContentType;
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment