[pve-devel] applied-series: [PATCH common/cluster 0/3] fix #4937: fix utf8 encoding issues while saving notification config
Fiona Ebner
f.ebner at proxmox.com
Mon Sep 11 14:50:20 CEST 2023
Am 30.08.23 um 14:37 schrieb Lukas Wagner:
> These patches should fix issues with certain special characters
> (e.g ü) in the notification configuration [1].
> Before, when setting a comment for an endpoint to certain values
> (e.g. 'für admins'), the resulting saved configuration would
> contain invalid UTF8 text.
>
> The reason for that was the configuration was returned from
> Rust as a proper utf8 string, however it was saved to the file
> system without specifying an encoding.
>
>
> [1] https://bugzilla.proxmox.com/show_bug.cgi?id=4937
>
applied-series, after discussing with Fabian, thanks!
We decided to make it a $force_utf8 flag instead of passing the encoding
as a string, and use the strict 'UTF-8' encoding rather than 'utf8'. See
the "UTF-8 vs. utf8 vs. UTF8" section in 'perldoc Encode' for more info.
I also moved the binmode() call to after the loop, where $fh is known to
be set.
We also found that file_get_contents() doesn't set Perl's UTF-8 flag for
strings even if the input is UTF-8, because it uses sysread(). It's fine
for the notification configs apparently, but going forward, we'll need
to be careful. One idea was an opt-in parameter for detecting UTF-8 and
setting the Perl string flag and using that for (most) cluster
filesystem files.
More information about the pve-devel
mailing list