Changeset 2133 for FCKeditor.Java/trunk
- Timestamp:
- 2008-06-25 09:17:42 (5 months ago)
- Location:
- FCKeditor.Java/trunk/java-core/src
- Files:
-
- 2 modified
-
main/java/net/fckeditor/tool/Compatibility.java (modified) (2 diffs)
-
test/java/net/fckeditor/tool/CompatibilityTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/tool/Compatibility.java
r2101 r2133 35 35 /** 36 36 * Checks if a browser's user agent string is compatible for the FCKeditor. 37 * <br />38 * Adapted from:39 * http://dev.fckeditor.net/browser/FCKeditor/releases/stable/fckeditor.php40 37 * 41 * @param userAgentStr ing38 * @param userAgentStr 42 39 * @return <code>true</code> if compatible otherwise <code>false</code> 43 40 */ … … 45 42 if (Utils.isEmpty(userAgentString)) 46 43 return false; 47 48 float version;44 45 String userAgentStr = userAgentString.toLowerCase(); 49 46 50 47 // IE 5.5+, check special keys like 'Opera' and 'mac', because there are some 51 48 // other browsers, containing 'MSIE' in there agent string! 52 if (userAgentString.indexOf("Opera") < 0 && userAgentString.indexOf("mac") < 0) { 53 version = getBrowserVersion(userAgentString, ".*MSIE ([\\d]+.[\\d]+).*"); 54 if (version != -1f && version >= 5.5f) 49 if (userAgentStr.indexOf("opera") < 0 && userAgentStr.indexOf("mac") < 0) { 50 if (getBrowserVersion(userAgentStr, ".*msie ([\\d]+.[\\d]+).*") >= 5.5f) 55 51 return true; 56 52 } 57 58 // for mozilla only, because all firefox versions are supported 59 version = getBrowserVersion(userAgentString, ".*Gecko/([\\d]+).*"); 60 if (version != -1f && version >= 20030210f) 53 54 // for all gecko based browsers 55 if (getBrowserVersion(userAgentStr, ".*rv:([\\d]+.[\\d]+).*") > 1.7f) 61 56 return true; 62 57 63 58 // Opera 9.5+ 64 version = getBrowserVersion(userAgentString, "Opera/([\\d]+.[\\d]+).*"); 65 if (version != -1f && version >= 9.5f) 66 return true; 67 version = getBrowserVersion(userAgentString, ".*Opera ([\\d]+.[\\d]+)"); 68 if (version != -1f && version >= 9.5f) 59 if (getBrowserVersion(userAgentStr, "opera/([\\d]+.[\\d]+).*") >= 9.5f 60 || getBrowserVersion(userAgentStr, ".*opera ([\\d]+.[\\d]+)") >= 9.5f) 69 61 return true; 70 62 71 63 // Safari 3+ 72 version = getBrowserVersion(userAgentString, ".*AppleWebKit/([\\d]+).*"); 73 if (version != -1f && version >= 522f) 64 if (getBrowserVersion(userAgentStr, ".*applewebkit/([\\d]+).*") >= 522f) 74 65 return true; 75 66 -
FCKeditor.Java/trunk/java-core/src/test/java/net/fckeditor/tool/CompatibilityTest.java
r1553 r2133 86 86 assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12")); 87 87 } 88 89 @Test 90 public void testFirefox30Linux() throws Exception { 91 assertTrue(Compatibility.check("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9pre) Gecko/2008040318 Firefox/3.0pre (Swiftfox)")); 92 } 88 93 89 94 @Test … … 111 116 assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.0; en) Opera 9.50")); 112 117 } 118 119 @Test 120 public void testEpaphany220Linux() throws Exception { 121 assertTrue(Compatibility.check("Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9b3) Gecko Epiphany/2.20")); 122 } 113 123 }