diff options
author | Zuul <zuul@review.opendev.org> | 2023-02-15 04:04:16 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-02-15 04:04:16 +0000 |
commit | b1b8c00ddd646c5ed51b36ffd260102c2e3873cd (patch) | |
tree | 9a71284e3bf6e7c59ad8fffd8b918a3cae2a01b6 /zuul | |
parent | 5922c66dd10fc2ba72683c173915be5df089cb2f (diff) | |
parent | ffc03cfcc16965cdc81c3f7b88f650788a8fe5de (diff) | |
download | zuul-b1b8c00ddd646c5ed51b36ffd260102c2e3873cd.tar.gz |
Merge "gerrit driver: fix bug around unicode branch names"
Diffstat (limited to 'zuul')
-rw-r--r-- | zuul/driver/gerrit/gerritconnection.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py index 0a1f0ee61..276365e1d 100644 --- a/zuul/driver/gerrit/gerritconnection.py +++ b/zuul/driver/gerrit/gerritconnection.py @@ -1643,7 +1643,10 @@ class GerritConnection(ZKChangeCacheMixin, ZKBranchCacheMixin, BaseConnection): def getInfoRefs(self, project: Project) -> Dict[str, str]: try: - data = self._uploadPack(project) + # Encode the UTF-8 data back to a byte array, as the size of + # each record in the pack is in bytes, and so the slicing must + # also be done on a byte-basis. + data = self._uploadPack(project).encode("utf-8") except Exception: self.log.error("Cannot get references from %s" % project) raise # keeps error information @@ -1662,7 +1665,9 @@ class GerritConnection(ZKChangeCacheMixin, ZKBranchCacheMixin, BaseConnection): plen -= 4 if len(data) - i < plen: raise Exception("Invalid data in info/refs") - line = data[i:i + plen] + # Once the pack data is sliced, we can safely decode it back + # into a (UTF-8) string. + line = data[i:i + plen].decode("utf-8") i += plen if not read_advertisement: read_advertisement = True |