summaryrefslogtreecommitdiff
path: root/zuul
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-02-15 04:04:16 +0000
committerGerrit Code Review <review@openstack.org>2023-02-15 04:04:16 +0000
commitb1b8c00ddd646c5ed51b36ffd260102c2e3873cd (patch)
tree9a71284e3bf6e7c59ad8fffd8b918a3cae2a01b6 /zuul
parent5922c66dd10fc2ba72683c173915be5df089cb2f (diff)
parentffc03cfcc16965cdc81c3f7b88f650788a8fe5de (diff)
downloadzuul-b1b8c00ddd646c5ed51b36ffd260102c2e3873cd.tar.gz
Merge "gerrit driver: fix bug around unicode branch names"
Diffstat (limited to 'zuul')
-rw-r--r--zuul/driver/gerrit/gerritconnection.py9
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