Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MacOS Catalina Regex issue #149

Merged
merged 3 commits into from
Jun 25, 2019
Merged

Fix MacOS Catalina Regex issue #149

merged 3 commits into from
Jun 25, 2019

Conversation

ajoy39
Copy link
Contributor

@ajoy39 ajoy39 commented Jun 20, 2019

Mac OS Catalina appends a hex code to the end of the path output by LSRegisters, the regex that finds all the chrome executables looked for a newline immediately following the end of the .app.

Now the regex finds the paths again, and hex code is trimmed off before being tested for file access and added to the array

Fixes #146

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

Mac OS Catalina appends a hex code to the end of the path output by LSRegisters, the regex that finds all the chrome executables looked for a newline immediately following the end of the .app.

Now the regex finds the paths again, and hex code is trimmed off before being tested for file access and added to the array
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much!

I would ask for a test but we don't have any at all for chrome-finder 😳

@@ -33,13 +33,13 @@ export function darwin() {

execSync(
`${LSREGISTER} -dump` +
' | grep -i \'google chrome\\( canary\\)\\?.app$\'' +
' | grep -i \'google chrome\\( canary\\)\\?.app.*$\'' +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a bit aggressive (it matches ~15 lines locally for me)

is there any narrower search we could put on it? a particular length limit perhaps or additional filtering on the JS side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a space between the .app and the wildcard to prevent the regex from returning subdirectories, that took me from 4 results down to 2. One of them is my actual correct chrome install and the other is a copy of chrome in my trash. I could limit the regex to the applications folder without too much trouble, but that could break the command for anyone who has it installed somewhere else. I'm not that great with regular expressions so I may need some help removing the "trashed" version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajoy39 Just an FYI, .*$ is redundant in most cases, because it matches everything (including nothing) up to the end of the string. It would have been better to remove $ altogether and have /google chrome(canary )?\.app/i make no assumptions about what characters follow it.

I amended this as part of #197, and felt I should let you know. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alhadis oh, thanks for letting me know! I’m not great with regex so any help is appreciated!

@@ -33,13 +33,13 @@ export function darwin() {

execSync(
`${LSREGISTER} -dump` +
' | grep -i \'google chrome\\( canary\\)\\?.app$\'' +
' | grep -i \'google chrome\\( canary\\)\\?.app .*$\'' +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now this matches nothing on pre-catalina versions like mine :)

how about let's just remove the $ business completely (leave as ?.app') and do the rest of our filtering in JS where it's a little easier to reason about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right, I didn't check that one on the Mojave mac mini before I pushed it up. I reverted that change, and put a check to pushing to the installations array to make sure items are unique. Between that and the canAccess() function that will ensure that only valid, unique chrome apps are found and added to the array.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this LGTM, but I'll probably want to follow this up with better testing in this file anyhow :)

would you mind donating the result of /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump in a text file for us or at least the section that has chrome versions to help us out with that? :)

@ajoy39
Copy link
Contributor Author

ajoy39 commented Jun 20, 2019

Sure thing, here's the chrome related stuff including entries for Chrome Helper and the Chrome.app that was in my trash.

log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for macOS Catalina
5 participants