Skip to content

Commit

Permalink
ZBUG-4538 Extracted content type through MIME for defang usage.Remove…
Browse files Browse the repository at this point in the history
…d the check for IE.

ZBUG-4538 Code refactored
  • Loading branch information
ashwinsahu19 committed Jan 3, 2025
1 parent 9c97615 commit c8ae28d
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ private static void sendbackOriginalDoc(InputStream is, String contentType, Stri
}
// defang when the html and svg attachment was requested with disposition inline
if (disp.equals(Part.INLINE) && isScriptableContent(contentType)) {
contentType = Mime.getContentType(contentType).toLowerCase();
BrowserDefang defanger = DefangFactory.getDefanger(contentType);
String content = defanger.defang(Mime.getTextReader(is, contentType, defaultCharset), true);
resp.setContentType(contentType);
Expand Down Expand Up @@ -616,10 +617,7 @@ public static void sendbackBinaryData(HttpServletRequest req, HttpServletRespons
}
PushbackInputStream pis = new PushbackInputStream(in, READ_AHEAD_BUFFER_SIZE);
boolean isSafe = false;
HttpUtil.Browser browser = HttpUtil.guessBrowser(req);
if (browser != HttpUtil.Browser.IE) {
isSafe = true;
} else if (disposition.equals(Part.ATTACHMENT)) {
if (Part.ATTACHMENT.equals(disposition)) {
isSafe = true;
if (isScriptableContent(contentType)) {
resp.addHeader("X-Download-Options", "noopen"); // ask it to save the file
Expand Down

0 comments on commit c8ae28d

Please sign in to comment.