public static boolean isMSIE6or7(String UA) { return org.nuxeo.common.utils.UserAgentMatcher.isMSIE6or7(UA); }
@Factory(value = "isMSIE6or7", scope = ScopeType.SESSION) public boolean isMSIE6or7() { FacesContext context = FacesContext.getCurrentInstance(); if (context != null) { HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String ua = request.getHeader("User-Agent"); return UserAgentMatcher.isMSIE6or7(ua); } else { return false; } }
/** * Encodes a {@code Content-Disposition} header. For some user agents the full RFC-2231 encoding won't be performed * as they don't understand it. * * @param filename the filename * @param inline {@code true} for an inline disposition, {@code false} for an attachment * @param userAgent the userAgent * @return a full string to set as value of a {@code Content-Disposition} header */ public static String encodeContentDisposition(String filename, boolean inline, String userAgent) { StringBuilder buf = new StringBuilder(inline ? "inline; " : "attachment; "); if (userAgent == null) { userAgent = ""; } if (isMSIE6or7(userAgent)) { // MSIE understands straight %-encoding buf.append("filename="); percentEscape(buf, filename); } else { // proper RFC2231 buf.append("filename*=UTF-8''"); percentEscape(buf, filename); } return buf.toString(); }
@Factory(value = "isMSIEorEdge", scope = ScopeType.SESSION) public boolean isMSIEorEdge() { FacesContext context = FacesContext.getCurrentInstance(); if (context != null) { HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String ua = request.getHeader("User-Agent"); return UserAgentMatcher.isMSIE6or7(ua) || UserAgentMatcher.isMSIE10OrMore(ua) || UserAgentMatcher.isMSEdge(ua); } else { return false; } }