velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1812138 - in /velocity/tools/trunk/velocity-tools-view/src/main: java/org/apache/velocity/tools/view/UAParser.java resources/org/apache/velocity/tools/view/ua-keywords.txt
Date Fri, 13 Oct 2017 14:57:28 GMT
Author: cbrisson
Date: Fri Oct 13 14:57:28 2017
New Revision: 1812138

URL: http://svn.apache.org/viewvc?rev=1812138&view=rev
Log:
[tools] BrowserTool: fix UA parsing for Gecko without minor version

Modified:
    velocity/tools/trunk/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/UAParser.java
    velocity/tools/trunk/velocity-tools-view/src/main/resources/org/apache/velocity/tools/view/ua-keywords.txt

Modified: velocity/tools/trunk/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/UAParser.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/UAParser.java?rev=1812138&r1=1812137&r2=1812138&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/UAParser.java
(original)
+++ velocity/tools/trunk/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/UAParser.java
Fri Oct 13 14:57:28 2017
@@ -33,11 +33,27 @@ public class UAParser
 
         public UAEntity(String n, String maj, String min)
         {
+            this(n, maj, min, false);
+        }
+        
+        public UAEntity(String n, String maj, String min, boolean wantsFullVersion)
+        {
             name = n;
             try
             {
                 majorVersion = maj == null ? -1 : Integer.valueOf(maj);
-                minorVersion = maj == null ? -1 : Integer.valueOf(min);
+                try
+                {
+                    minorVersion = maj == null ? -1 : Integer.valueOf(min);
+                }
+                catch (NumberFormatException nfe)
+                {
+                    minorVersion = -1;
+                    if (wantsFullVersion)
+                    {
+                        majorVersion = -1;
+                    }
+                }
             }
             catch (NumberFormatException nfe)
             {
@@ -152,7 +168,7 @@ public class UAParser
             String alternate = browserTranslationMap.get(entity.toLowerCase());
             if (alternate != null) { entity = alternate; }
             if ("Navigator".equals(entity)) { entity = "Netscape"; }
-            browser = new UAEntity(entity, major, minor);
+            browser = new UAEntity(entity, major, minor, true);
             if ("Edge".equals(entity) && renderingEngine == null) { renderingEngine
= new UAEntity("EdgeHTML", major, minor); }
         }
 

Modified: velocity/tools/trunk/velocity-tools-view/src/main/resources/org/apache/velocity/tools/view/ua-keywords.txt
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view/src/main/resources/org/apache/velocity/tools/view/ua-keywords.txt?rev=1812138&r1=1812137&r2=1812138&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view/src/main/resources/org/apache/velocity/tools/view/ua-keywords.txt
(original)
+++ velocity/tools/trunk/velocity-tools-view/src/main/resources/org/apache/velocity/tools/view/ua-keywords.txt
Fri Oct 13 14:57:28 2017
@@ -334,6 +334,7 @@ martha=engine
 presto=engine
 prince=engine
 trident=engine
+gecko=engine
 
 # operating systems
 amigaos=os,desktop



Mime
View raw message