#3262 Fix parsing of URLs with port numbers
Merged 2 years ago by tkopecek. Opened 2 years ago by alexi.
alexi/koji fix_3212  into  master

Fix parsing of URLs with port numbers
Alex Iribarren • 2 years ago  
file modified
+1 -1
@@ -301,7 +301,7 @@ 

          if password is not None and not allow_password:

              raise koji.GenericError('username:password format not supported: %s:%s'

                                      % (user, password))

-         netloc = parsed_url.hostname

+         netloc = userhost[-1]

  

          # check for empty path before we apply normpath

          if not path:

file modified
+14
@@ -53,6 +53,7 @@ 

              "svn+ssh://server/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",

              "cvs://server/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",

              "cvs+ssh://server/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",

+             "cvs+ssh://server:80/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",

          ]

          bad = [

              "http://localhost/foo.html",
@@ -98,6 +99,19 @@ 

          self.assertEqual(scm.source_cmd, ['make', 'sources'])

          self.assertEqual(scm.scmtype, 'GIT')

  

+     def test_with_port(self):

+         url = "git+ssh://user@server:80/foo.git#bab0c73900241ef5c465d7e873e9d8b34c948e67"

+         scm = SCM(url)

+         self.assertEqual(scm.scheme, 'git+ssh://')

+         self.assertEqual(scm.user, 'user')

+         self.assertEqual(scm.host, 'server:80')

+         self.assertEqual(scm.repository, '/foo.git')

+         self.assertEqual(scm.module, '')

+         self.assertEqual(scm.revision, 'bab0c73900241ef5c465d7e873e9d8b34c948e67')

+         self.assertEqual(scm.use_common, True)

+         self.assertEqual(scm.source_cmd, ['make', 'sources'])

+         self.assertEqual(scm.scmtype, 'GIT+SSH')

+ 

      def test_assert_allowed_basic(self):

          scm = SCM("git://scm.example.com/path1#1234")

  

PR #3212 introduced a regression whereby port numbers in a URL were silently dropped. This commit fixes that and adds a test to catch similar errors in the future.

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-done

2 years ago

Commit ce0ea82 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago