gpg --with-colon contains non-UTF-8 data

Uwe Kleine-König u.kleine-koenig at baylibre.com
Tue May 6 21:58:33 CEST 2025


Hello,

[I would have put this in the bug tracker, but I cannot create an
account there. The hint says to request access on the mailing list, but
https://lists.gnupg.org/pipermail/gnupg-users/2025-April/067578.html
didn't work. So here comes another bug report on this mailing list.]

	$ gpg --version
	gpg (GnuPG) 2.4.7
	libgcrypt 1.11.0
	Copyright (C) 2024 g10 Code GmbH
	License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
	This is free software: you are free to change and redistribute it.
	There is NO WARRANTY, to the extent permitted by law.

	Home: /home/uwe/.gnupg
	Supported algorithms:
	Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
	Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
		CAMELLIA128, CAMELLIA192, CAMELLIA256
	Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
	Compression: Uncompressed, ZIP, ZLIB, BZIP2

	$ gpg --recv-keys --keyserver hkps://keyserver.ubuntu.com DE6162B5616BA9C9CAAC03074A55C497F744F705
	...
	$ gpg --list-keys --with-colons DE6162B5616BA9C9CAAC03074A55C497F744F705 | file -
	/dev/stdin: ISO-8859 text

file considers this ISO-8859 because one of the UIDs isn't proper UTF-8,
but "Toke Høiland-Jørgensen <toke at tohojo.dk>" encoded in latin1.

It's clear that this UID is invalid, but I'd claim that there is a bug
in the documentation (gpg(1) claims in the description for --with-colons
that the output is UTF-8) or in gpg itself (because it doesn't quote the
invalid chars).

Fun fact: Without --with-colons the UID is emitted as:

	uid           [ unknown] Toke H\xf8\x69land-J\xf8\x72gensen <toke at tohojo.dk>

which is UTF-8 and needlessly encodes the i and the r following the two
ø as hex escape.

I wonder if cleaning the key should remove that UID?

Best regards
U\x77e
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20250506/cf3e7fc5/attachment.sig>


More information about the Gnupg-users mailing list