Skip to content

Commit 34f67c9

Browse files
dedekindringgitster
authored andcommitted
git-p4: fix bug with encoding of p4 client name
The Perforce client name can contain arbitrary characters which do not decode to UTF-8. Use the fallback strategy implemented in metadata_stream_to_writable_bytes() also for the client name. Signed-off-by: Kilian Kilger <[email protected]> Reviewed-by: Tao Klerks <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4a4b31 commit 34f67c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git-p4.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,12 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False,
854854
if bytes is not str:
855855
# Decode unmarshalled dict to use str keys and values, except for:
856856
# - `data` which may contain arbitrary binary data
857-
# - `desc` or `FullName` which may contain non-UTF8 encoded text handled below, eagerly converted to bytes
857+
# - `desc` or `client` or `FullName` which may contain non-UTF8 encoded text handled below, eagerly converted to bytes
858858
# - `depotFile[0-9]*`, `path`, or `clientFile` which may contain non-UTF8 encoded text, handled by decode_path()
859859
decoded_entry = {}
860860
for key, value in entry.items():
861861
key = key.decode()
862-
if isinstance(value, bytes) and not (key in ('data', 'desc', 'FullName', 'path', 'clientFile') or key.startswith('depotFile')):
862+
if isinstance(value, bytes) and not (key in ('data', 'desc', 'FullName', 'path', 'clientFile', 'client') or key.startswith('depotFile')):
863863
value = value.decode()
864864
decoded_entry[key] = value
865865
# Parse out data if it's an error response
@@ -871,6 +871,8 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False,
871871
continue
872872
if 'desc' in entry:
873873
entry['desc'] = metadata_stream_to_writable_bytes(entry['desc'])
874+
if 'client' in entry:
875+
entry['client'] = metadata_stream_to_writable_bytes(entry['client'])
874876
if 'FullName' in entry:
875877
entry['FullName'] = metadata_stream_to_writable_bytes(entry['FullName'])
876878
if cb is not None:

0 commit comments

Comments
 (0)