From a5bf5b8d57b2b667d3e5920d836ee68373c72608 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 21 Jun 2012 20:16:13 -0300 Subject: [PATCH] Fix Browser detection filter. --- .../filter/BrowserSupportInterceptor.java | 21 ++++---- .../com/wisemapping/filter/UserAgent.java | 22 ++++----- .../WEB-INF/classes/messages.properties | 2 +- .../WEB-INF/classes/messages_es.properties | 2 +- .../WEB-INF/classes/messages_fr.properties | 2 +- .../main/webapp/WEB-INF/defs/definitions.xml | 17 +++++-- .../webapp/WEB-INF/wisemapping-servlet.xml | 48 +++++++++---------- .../main/webapp/jsp/browserNotSupported.jsp | 24 +++++----- 8 files changed, 72 insertions(+), 66 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/BrowserSupportInterceptor.java b/wise-webapp/src/main/java/com/wisemapping/filter/BrowserSupportInterceptor.java index bdb8cab6..2e37c327 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/BrowserSupportInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/BrowserSupportInterceptor.java @@ -18,6 +18,7 @@ package com.wisemapping.filter; +import org.jetbrains.annotations.NotNull; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import javax.servlet.http.HttpServletRequest; @@ -26,17 +27,17 @@ import javax.servlet.http.HttpSession; import com.wisemapping.exceptions.UnsupportedBrowserException; -import java.util.List; +import java.util.Set; public class BrowserSupportInterceptor extends HandlerInterceptorAdapter { - private List exclude; + private Set exclude; public static final String USER_AGENT = "wisemapping.userAgent"; - public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception { + public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { - final String servletPath = httpServletRequest.getServletPath(); - if (exclude != null && !exclude.contains(servletPath)) { - final HttpSession session = httpServletRequest.getSession(false); + final String requestUri = request.getRequestURI(); + if (exclude != null && !exclude.contains(requestUri)) { + final HttpSession session = request.getSession(false); // Try to loaded from the request ... UserAgent userAgent = null; @@ -46,7 +47,7 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter { // I could not loaded. I will create a new one... if (userAgent == null) { - userAgent = UserAgent.create(httpServletRequest); + userAgent = UserAgent.create(request); if (session != null) { session.setAttribute(USER_AGENT, userAgent); } @@ -61,11 +62,7 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter { } - public List getExclude() { - return exclude; - } - - public void setExclude(List exclude) { + public void setExclude(Set exclude) { this.exclude = exclude; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/UserAgent.java b/wise-webapp/src/main/java/com/wisemapping/filter/UserAgent.java index ccd487f4..5104352e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/UserAgent.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/UserAgent.java @@ -114,7 +114,7 @@ public class UserAgent implements Serializable { this.os = parseOS(productDetails); - if (userAgentHeader.indexOf("MSIE") != -1) { + if (userAgentHeader.contains("MSIE")) { // Explorer Browser : http://msdn2.microsoft.com/en-us/library/ms537503.aspx // Format: Mozilla/MozVer (compatible; MSIE IEVer[; Provider]; Platform[; Extension]*) [Addition] // SampleTest: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;) @@ -128,14 +128,14 @@ public class UserAgent implements Serializable { // Explorer Parse ... this.product = Product.EXPLORER; - this.hasGCFInstalled = productDetails.indexOf("chromeframe") != -1; - } else if (userAgentHeader.indexOf("iCab") != -1 || userAgentHeader.indexOf("Safari") != -1) { + this.hasGCFInstalled = productDetails.contains("chromeframe"); + } else if (userAgentHeader.contains("iCab") || userAgentHeader.contains("Safari")) { // Safari: //Formats: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1 //Chrome: //Formats: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7" String versionStr = ""; - if (userAgentHeader.indexOf("Chrome") != -1) { + if (userAgentHeader.contains("Chrome")) { this.product = Product.CHROME; versionStr = userAgentHeader.substring(userAgentHeader.indexOf("Chrome") + 7, userAgentHeader.lastIndexOf(" ")); } else { @@ -145,11 +145,11 @@ public class UserAgent implements Serializable { parseVersion(versionStr); - } else if (userAgentHeader.indexOf("Konqueror") != -1) { + } else if (userAgentHeader.contains("Konqueror")) { this.product = Product.KONQUEOR; - } else if (userAgentHeader.indexOf("KMeleon") != -1) { + } else if (userAgentHeader.contains("KMeleon")) { this.product = Product.KMELEON; - } else if (userAgentHeader.indexOf("Gecko") != -1) { + } else if (userAgentHeader.contains("Gecko")) { // Firefox/Mozilla/Camino: // Mozilla/MozVer (Platform; Security; SubPlatform; Language; rv:Revision[; Extension]*) Gecko/GeckVer [Product/ProdVer] // SampleTest: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20050302 Firefox/0.9.6 @@ -195,7 +195,7 @@ public class UserAgent implements Serializable { } - } else if (userAgentHeader.indexOf("Opera") != -1) { + } else if (userAgentHeader.contains("Opera")) { // Opera: // Samples: Opera/9.0 (Windows NT 5.1; U; en) // Opera/8.5 (Macintosh; PPC Mac OS X; U; en) @@ -212,14 +212,14 @@ public class UserAgent implements Serializable { } parseVersion(productVersion); - } else if (userAgentHeader.indexOf("4.7") != -1) { + } else if (userAgentHeader.contains("4.7")) { this.product = Product.NETSCAPE; - } else if (userAgentHeader.indexOf("Lynx") != -1) { + } else if (userAgentHeader.contains("Lynx")) { this.product = Product.LYNX; } else { // It's a robot .. for (String botAgent : botAgents) { - if (userAgentHeader.indexOf(botAgent) != -1) { + if (userAgentHeader.contains(botAgent)) { // set a key in the session, so the next time we don't have to manually // detect the robot again this.product = Product.ROBOT; diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties index fbde4c95..fb4ed472 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties @@ -153,7 +153,7 @@ EMPTY_RECENT_MINDMAP_TABLE=No recent maps TAGS_DETAILS=Add tags you maps is very simple. Try! TAG_IT=Tag It PUBLISH_IT=Publish It -USUPPORTED_BROWSER=Unsupported Browser +UNSUPPORTED_BROWSER=Unsupported Browser FIELD_REQUIRED_MSG=Fields marked with an asterisk * are required. TAGS_MSG=Tagging is a simple way to keep your maps in order and help other people to find your public maps COMMA_SEPARATED_EMAILS=Comma separated emails diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties index b74b7613..de50d0d0 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties @@ -151,7 +151,7 @@ EMPTY_RECENT_MINDMAP_TABLE=No hay mapas recientes TAGS_DETAILS=Agregar etiquetas a sus mapas en muy facil! Intentelo! TAG_IT=Etiquetalo! PUBLISH_IT=Publicalo! -USUPPORTED_BROWSER=Navegador no soportado +UNSUPPORTED_BROWSER=Navegador no soportado FIELD_REQUIRED_MSG=Fields marked with an asterisk * are required. TAGS_MSG=Tagging is a simple way to keep your maps in order and help other people to find your public maps COMMA_SEPARATED_EMAILS=E-mails separados por comas diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties index 65a2159a..1b396361 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties @@ -154,7 +154,7 @@ EMPTY_RECENT_MINDMAP_TABLE = Aucune carte r\u00e9cente TAGS_DETAILS = Ajoutez des mots-cl\u00e9s \u00e0 vos maps en 1 clic. TAG_IT = Taguer PUBLISH_IT = Publier -USUPPORTED_BROWSER = Navigateur non support\u00e9 +UNSUPPORTED_BROWSER = Navigateur non support\u00e9 FIELD_REQUIRED_MSG=Les champs marqu\u00e9s avec une ast\u00e9risque sont requis. COMMA_SEPARATED_EMAILS = S\u00e9parer les adresses email par une virgule diff --git a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml index 51989a13..34bf48d0 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml @@ -10,6 +10,7 @@ + @@ -57,6 +58,11 @@ + + + + + @@ -82,9 +88,14 @@ - - - + + + + + + + + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 7d75d883..b6430755 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -15,6 +15,29 @@ + + + + + + / + /index.jsp + /c/home + /c/j_spring_security + /c/login + /service/ + /c/maps/*/embed + /c/maps/*/public + /c/embeddedView + /c/user/resetPassword + /c/user/registration + + + + + + + @@ -50,11 +73,6 @@ - - - - @@ -67,26 +85,6 @@ - - - - / - /index.jsp - /c/home - /c/login - /c/user/registration - /c/captcha - /c/publicView - /service/* - /c/search - /c/keyboard - /c/renameMap - /c/embeddedView - /c/user/resetPassword - - - - diff --git a/wise-webapp/src/main/webapp/jsp/browserNotSupported.jsp b/wise-webapp/src/main/webapp/jsp/browserNotSupported.jsp index 9f6c0ed5..569e27f9 100644 --- a/wise-webapp/src/main/webapp/jsp/browserNotSupported.jsp +++ b/wise-webapp/src/main/webapp/jsp/browserNotSupported.jsp @@ -1,21 +1,21 @@ <%@ include file="/jsp/init.jsp" %> -

- -

+

Opps!!!. Your browser is not currently supported

-

You are using an unsupported browser.

- -

Although you can use our site with that browser, some features may not be functional.

-WiseMapping is optimized for use with: +

Your browser has not been fully tested and it might not be completely functional. WiseMapping has been optimized + for:

    -
  • Internet Explorer 7.0 or greater
  • -
  • Firefox 3.0 or greater
  • +
  • Chrome 19 or greater
  • +
  • Firefox 11.0 or greater
  • Opera 11 or greater
  • Safari 5 or greater
  • +
  • Internet Explorer 8.0 or greater
+

+ Try again with one of the browsers previously listed. +

- We are working to support more browser in the future. Stay tuned ! - -

+ Note: Browsers are listed based on performance and + hours of testing invested by our team. +