Skip to content
New issue

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

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

Already on GitHub? # to your account

FormulaURILoader: use regex to validate refs before attempting to cast #17766

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Jul 15, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Fixes #17752

This PR updates Formulary::FromURILoader to match the cask equivalent and check the ref against a URI regex. This avoids trying to run URI() where the argument is something that will throw a bad URI error (e.g. a string with spaces).

Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

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

This approach makes sense to me. It might even be simpler to just catch the URI error in the .try_new method assuming there isn't a noticeable performance difference. Then you'd be able to avoid the regex caching.

@apainintheneck apainintheneck merged commit 4aae003 into master Jul 18, 2024
24 checks passed
@apainintheneck apainintheneck deleted the fix-formula-uri-loader branch July 18, 2024 03:07
@Rylan12
Copy link
Member Author

Rylan12 commented Jul 18, 2024

This approach makes sense to me. It might even be simpler to just catch the URI error in the .try_new method assuming there isn't a noticeable performance difference. Then you'd be able to avoid the regex caching.

Sorry, I missed this comment before. I'm not opposed to doing it this way, but the regex is provided by URI seemingly for this purpose so in some ways this seems like the intended way to do it. But no really preference either way

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

Successfully merging this pull request may close these issues.

Error: bad URI(is not URI?): when search item contains a space
3 participants