Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2016-01-21 18:24:59 +0000
committerBrian de Alwis2016-01-21 18:24:59 +0000
commitb48bd1c89403779fdcd1caf195a6af194c4eb92a (patch)
treeb9b7d828bdce8e84c4d9bfe1eee82c94500c5c8d
parenta5c2de2fb78071d24a77b1ffc7c945cd095a08ee (diff)
downloadeclipse.platform.ui-b48bd1c89403779fdcd1caf195a6af194c4eb92a.tar.gz
eclipse.platform.ui-b48bd1c89403779fdcd1caf195a6af194c4eb92a.tar.xz
eclipse.platform.ui-b48bd1c89403779fdcd1caf195a6af194c4eb92a.zip
Bug 486298 - [browser][osx] External Browser doesn't properly verify that browser location exists
-rw-r--r--bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/BrowserDescriptorDialog.java4
-rw-r--r--bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/ExternalBrowserInstance.java17
2 files changed, 14 insertions, 7 deletions
diff --git a/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/BrowserDescriptorDialog.java b/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/BrowserDescriptorDialog.java
index 7915308c4d2..cb5497426e7 100644
--- a/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/BrowserDescriptorDialog.java
+++ b/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/BrowserDescriptorDialog.java
@@ -184,8 +184,8 @@ public class BrowserDescriptorDialog extends Dialog {
protected void okPressed() {
// do simple field validation to at least ensure target directory entered is valid pathname
try {
- File file = new File(browser.getLocation());
- if(!file.isFile() && !Util.isMac()){
+ File file = new File(browser.getLocation());
+ if (!(file.isFile() || (Util.isMac() && ExternalBrowserInstance.isMacAppBundle(file)))) {
WebBrowserUtil.openError(Messages.locationInvalid);
return;
}
diff --git a/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/ExternalBrowserInstance.java b/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/ExternalBrowserInstance.java
index 5cd5376a285..4a677b3716a 100644
--- a/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/ExternalBrowserInstance.java
+++ b/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/ExternalBrowserInstance.java
@@ -129,13 +129,20 @@ public class ExternalBrowserInstance extends AbstractWebBrowser {
* @return true if the location appears to be a Mac Application bundle
* (.app)
*/
- private boolean isMacAppBundle(String location) {
+ public static boolean isMacAppBundle(String location) {
+ return isMacAppBundle(new File(location));
+ }
+
+ /**
+ * @return true if the location appears to be a Mac Application bundle
+ * (.app)
+ */
+ public static boolean isMacAppBundle(File location) {
// A very quick heuristic based on Apple's Bundle Programming Guide
// https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW19
- File bundleLoc = new File(location);
- File macosDir = new File(new File(bundleLoc, "Contents"), "MacOS"); //$NON-NLS-1$ //$NON-NLS-2$
- File plist = new File(new File(bundleLoc, "Contents"), "Info.plist"); //$NON-NLS-1$ //$NON-NLS-2$
- return bundleLoc.isDirectory() && macosDir.isDirectory() && plist.isFile();
+ File macosDir = new File(new File(location, "Contents"), "MacOS"); //$NON-NLS-1$ //$NON-NLS-2$
+ File plist = new File(new File(location, "Contents"), "Info.plist"); //$NON-NLS-1$ //$NON-NLS-2$
+ return location.isDirectory() && macosDir.isDirectory() && plist.isFile();
}
private String join (String delim, String ... data) {

Back to the top