homebysix / recipe-robot

A kick ass tool for creating AutoPkg recipes.
Apache License 2.0
300 stars 28 forks source link

Sparkle Feed Explosion for non-Sparkle feed #182

Closed apizz closed 3 years ago

apizz commented 3 years ago

Describe the bug Attempting to create recipes with https://www.macpostgresclient.com/download.php, which is not a Sparkle feed to my knowledge, causes Recipe Robot to explode.

To Reproduce Steps to reproduce the behavior:

  1. Open Recipe Robot
  2. Enter https://www.macpostgresclient.com/download.php URL
  3. Watch explode!

Expected behavior Recipes created.

Screenshots

Output:

Processing: https://www.macpostgresclient.com/download.php
Input path looks like a Sparkle feed.
    Sparkle feed is: https://www.macpostgresclient.com/download.php
[ERROR] Recipe Robot exploded with unexpected error: 'utf-8' codec can't decode byte 0xaf in position 59: invalid start byte
Traceback (most recent call last):
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe-robot", line 92, in main
    process_input_path(facts)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/inspect.py", line 161, in process_input_path
    facts = inspect_func(input_path, args, facts)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/inspect.py", line 1891, in inspect_sparkle_feed_url
    raw_xml = curler.download(checked_url, headers=headers, text=True)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/curler.py", line 174, in download
    output = download_with_curl(curl_cmd, text=text)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/curler.py", line 160, in download_with_curl
    curl_cmd, text=text, capture_output=capture_output
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/curler.py", line 150, in execute_curl
    text=text,
  File "/Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7/subprocess.py", line 490, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7/subprocess.py", line 964, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7/subprocess.py", line 1755, in _communicate
    self.stdout.errors)
  File "/Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7/subprocess.py", line 841, in _translate_newlines
    data = data.decode(encoding, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaf in position 59: invalid start byte

                                    _[]_
                                    [xx]
                                   q-||-p
                                     ||
                                   _/  \_



Desktop (please complete the following information):

Additional context Add any other context about the problem here.

homebysix commented 3 years ago

Good catch. I've cautiously added some code in 326ad0f that detects common download content-types and redirects Recipe Robot's effort from "inspect Sparkle feed" to "inspect download URL." That seems to solve the problem for your example input. I'll do some testing to make sure the change doesn't break parsing for any actual Sparkle feeds, and tentatively add this change to v2.2.0.

apizz commented 3 years ago

@homebysix this does not appear to be fixed in v2.2.0. When I enter the URL, I get a pinwheel and no visual output. Recipe Robot becomes unresponsive and have to force quit.

apizz commented 3 years ago

Trying the URL from #178 produces same behavior.

This is on 10.15.7 (19H114) Mac.

apizz commented 3 years ago

OOOoo I'm an idiot. The Mac I'm testing with I forgot doesn't have autopkg installed ...

apizz commented 3 years ago

Sorry for the false alarm, confirmed this is now working as expected.

Screen Shot 2020-12-17 at 12 02 41 PM