Bug 471499 - Spaces in file system label are displayed as underscores
Summary: Spaces in file system label are displayed as underscores
Status: RESOLVED FIXED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (show other bugs)
Version: 23.04.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-27 12:19 UTC by Paul Worrall
Modified: 2023-07-03 23:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 23.08.0


Attachments
screenshot (118.08 KB, image/png)
2023-06-27 12:19 UTC, Paul Worrall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Worrall 2023-06-27 12:19:27 UTC
Created attachment 159925 [details]
screenshot

SUMMARY
If a filesystem label has a space in it, partitionmanager displays it as an underscore causing confusion if trying to use the label elsewhere (e.g. in /etc/fstab or kernel parameter)

STEPS TO REPRODUCE
1. Assign a label with a space in it to a filesystem
2. Display the filesystem in partitionmanager

OBSERVED RESULT
Label is displayed with the space replaced by an underscore

EXPECTED RESULT
Label is displayed unchanged

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Graphics Platform: Wayland

ADDITIONAL INFORMATION
Confirmed with btrfs and ext4
Comment 1 Andrius Štikonas 2023-06-27 20:05:33 UTC
Oh, that seems to be coming from udev...
I ran udevadm command manually and it returns:

ID_FS_LABEL=rootfs_test
ID_FS_LABEL_ENC=rootfs\x20test

So we were reading ID_FS_LABEL but I guess we should read ID_FS_LABEL_ENC and decode it.

https://invent.kde.org/system/kpmcore/-/blob/master/src/plugins/sfdisk/sfdiskbackend.cpp#L636
Comment 2 Andrius Štikonas 2023-06-27 23:52:32 UTC
Hmm, there doesn't seem to be canonical way to decode blkid strings in Qt.

Qt has a internal function to do that https://github.com/qt/qtbase/blob/9a320b037ce7b63c5f9de6fbb4e391612e857a95/src/corelib/io/qstorageinfo_unix.cpp#L456 which we could presumably "steal" it.

But tt seems that it incorrectly decodes backslashes...

Christian, would you happen to remember why backslashes are ignored in qstorageinfo_unix.cpp::decodeFsEncString
(// but not the backslash to prevent collisions)

Because of that conditional, backslash is not decoded and it does seem correct to me. For example, I created a label called
rootfs test\test
blkid then encodes it to rootfs\x20test\x5ctest
which your function decoded to rootfs test\x5ctest
Comment 3 Andrius Štikonas 2023-07-03 23:42:09 UTC
Git commit 4490081c7acc60ff9a9a158cf8af4d7ed26a57b4 by Andrius Štikonas.
Committed on 03/07/2023 at 23:42.
Pushed by stikonas into branch 'master'.

Obtain file system label from ID_FS_LABEL_ENC.

M  +1    -1    src/core/operationrunner.cpp
M  +35   -3    src/plugins/sfdisk/sfdiskbackend.cpp

https://invent.kde.org/system/kpmcore/-/commit/4490081c7acc60ff9a9a158cf8af4d7ed26a57b4