From 6d350fa8522f6f4a749fb1e9fd00242d26edf8e2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 7 Nov 2024 23:41:02 +0100 Subject: [PATCH] MT#61052 NGCP::Template::Plugin::Utils: Do not generate bogus YAML on empty string When we pass an empty string the current to_yaml() function generates broken YAML such as "--- ''", which then breaks code parsing that expecting valid YAML. If we pass an empty string, return an empty string as well. (cherry picked from commit ae2d6e6ed28e63aca03e08cf67722c44e73fd1d3) (cherry picked from commit 81a79af51ee019076df6958ecc694365a4a28198) Change-Id: I8743bed2ca9888409a2f74fa0012f65b7b307e21 --- lib/NGCP/Template/Plugin/Utils.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/NGCP/Template/Plugin/Utils.pm b/lib/NGCP/Template/Plugin/Utils.pm index 21adc8b5..3c40f07a 100644 --- a/lib/NGCP/Template/Plugin/Utils.pm +++ b/lib/NGCP/Template/Plugin/Utils.pm @@ -40,6 +40,7 @@ sub to_config_general { sub to_yaml { my ($self, @params) = @_; + return q{} unless $params[0]; return YAML::XS::Dump($params[0]); }