all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH common v4 1/5] file: set contents: use strict UTF-8 encoding with $force_utf8
Date: Tue, 10 Mar 2026 11:13:30 +0100	[thread overview]
Message-ID: <20260310101631.32870-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260310101631.32870-1-f.ebner@proxmox.com>

'perldoc Encode' states:

> "UTF-8" means UTF-8 in its current sense, which is conservative and
> strict and security-conscious, whereas "utf8" means UTF-8 in its
> former sense, which was liberal and loose and lax.

Currently, the following callers use the $force_utf8 flag:

1. Notification config
2. The SDN fabrics config
3. The PBS password file

The first two pass the contents to Rust, and the latter already uses
the strict 'UTF-8' encoding when decoding. So in all cases, after this
patch, any potential issues are just caught earlier, before writing.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/File.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/File.pm b/src/PVE/File.pm
index 7d0f7ab..89884a8 100644
--- a/src/PVE/File.pm
+++ b/src/PVE/File.pm
@@ -60,7 +60,7 @@ sub file_set_contents($filename, $data, $perm = 0644, $force_utf8 = 0) {
         die "unable to open file '$tmpname' - $!\n" if !$fh;
 
         if ($force_utf8) {
-            $data = encode("utf8", $data);
+            $data = encode("UTF-8", $data);
         } else {
             # Encode wide characters with print before passing them to syswrite
             my $unencoded_data = $data;
-- 
2.47.3





  reply	other threads:[~2026-03-10 10:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 10:13 [RFC common/cluster v4 0/5] cluster files: support registering UTF-8 configuration file Fiona Ebner
2026-03-10 10:13 ` Fiona Ebner [this message]
2026-03-10 10:13 ` [PATCH common v4 2/5] section config: prepare for supporting UTF-8 encoded configurations Fiona Ebner
2026-03-10 10:13 ` [PATCH cluster v4 3/5] cfs register file: avoid implicit return Fiona Ebner
2026-03-10 10:13 ` [PATCH cluster v4 4/5] d/control: add versioned breaks for libpve-access-control Fiona Ebner
2026-03-10 10:13 ` [PATCH cluster v4 5/5] cluster files: support registering UTF-8 configuration file Fiona Ebner
2026-03-10 10:40   ` Hannes Laimer
2026-03-10 11:01     ` Fiona Ebner
2026-03-10 11:47       ` Hannes Laimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260310101631.32870-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal