#384 Fix html unescaped urls
Merged 4 years ago by ngompa. Opened 4 years ago by blackfalcon.
blackfalcon/FedoraReview fix-unescape-urls  into  master

file modified
+3 -2
@@ -19,6 +19,7 @@ 

  """

  import os.path

  from six.moves.urllib.request import urlretrieve

+ from six.moves.urllib.parse import unquote

  

  from bs4 import BeautifulSoup

  
@@ -64,13 +65,13 @@ 

          urls = self._find_urls_by_ending(".src.rpm")

          if not urls:

              raise self.BugError("Cannot find source rpm URL")

-         self.srpm_url = urls[0]

+         self.srpm_url = unquote(urls[0])

  

      def find_spec_url(self):

          urls = self._find_urls_by_ending(".spec")

          if not urls:

              raise self.BugError("Cannot find spec file URL")

-         self.spec_url = urls[0]

+         self.spec_url = unquote(urls[0])

  

      def get_location(self):

          return self.bug_url

Previously the spec url was not being unescaped. This led to the folders not being unescaped too, in which case python starts seeing % as format characters causing the following error:

$ fedora-review -b 1797524           

INFO: Processing bugzilla bug: 1797524
INFO: Getting .spec and .srpm Urls from : 1797524
INFO:   --> SRPM url: https://dl.bintray.com/astrorama/archive/sourcextractor++-0.8-1.fc31.src.rpm
INFO:   --> Spec url: https://raw.githubusercontent.com/astrorama/copr/b3791574b45acf09c7604535d6057cc273fd6b58/SourceXtractor%2B%2B/sourcextractor%2B%2B.spec
INFO: Using review directory: /home/blackfalcon/1797524-sourcextractor%2B%2B

ERROR: unsupported format character 'B' (0x42) at index 42
Traceback (most recent call last):
  File "/usr/libexec/mock/mock", line 1026, in <module>
    exitStatus = main()
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 655, in main
    util.set_config_opts_per_cmdline(config_opts, options, args)
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 1359, in set_config_opts_per_cmdline
    if is_in_dir(config_opts['resultdir'] % config_opts, rootdir):
ValueError: unsupported format character 'B' (0x42) at index 42

This commit provides the fix for this situation replacing unescape code with their single-character equivalent.

Pull-Request has been merged by ngompa

4 years ago
Metadata