Skip to content

Commit

Permalink
Merge pull request #376 from OneBusAway/utf8
Browse files Browse the repository at this point in the history
Use UTF-8 as character encoding for XML responses
  • Loading branch information
aaronbrethorst authored Oct 1, 2024
2 parents 8628b85 + 1b2b0be commit 30c58ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

public class CustomJsonLibHandler extends AbstractContentTypeHandler {

private String defaultEncoding = "ISO-8859-1";
private ObjectMapper mapper = new ObjectMapper();

public void toObject(ActionInvocation invocation, Reader in, Object target) throws IOException {
Expand Down Expand Up @@ -90,9 +89,6 @@ public String getContentType() {
if(callback != null){
return "application/javascript";
}
// we used to set charset for callbacks
// after Jackson upgrade to 2.12.0 this no longer works
//return "application/json;charset=" + this.defaultEncoding;
return "application/json";
}

Expand All @@ -102,6 +98,6 @@ public String getExtension() {

@Inject("struts.i18n.encoding")
public void setDefaultEncoding(String val) {
this.defaultEncoding = val;
/* nop - TODO: can this just be removed? */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected void doExecute(String finalLocation, ActionInvocation invocation)
HttpServletResponse response = ServletActionContext.getResponse();
RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation);
response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");
dispatcher.include(request, response);
}

Expand Down

0 comments on commit 30c58ed

Please sign in to comment.