From 21583f83d553f872fa46455731fd3012d630278e Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 23 Jun 2023 02:49:42 +0000 Subject: [PATCH] Bug 31393: Use _content as a placeholder when parsing koha-conf.xml This patch uses '_content' instead of 'content' as a placeholder when parsing koha-conf.xml, so that elements with a "content" attribute don't get parsed incorrectly (like with shibboleth config). Test plan: 0. Apply patch 1. echo 'flush_all' | nc -q 1 memcached 11211 2. koha-plack --reload kohadev 3. Add Shibboleth config to koha-conf.xml userid 4. vi Koha/Config.pm 5. Dump out the $config from the read_from_file() function 6. Note that the following is shown: 'branchcode' => { 'content' => 'foo' } 7. Note that the following is NOT shown: 'branchcode' => 'foo' 8. git restore Koha/Config.pm 9. Rejoice! For bonus points, you can actually do a full SAML test and make sure the Shibboleth integration works as expected --- Koha/Config.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/Config.pm b/Koha/Config.pm index eb0671dc2e..56883955be 100644 --- a/Koha/Config.pm +++ b/Koha/Config.pm @@ -217,7 +217,7 @@ sub _read_from_dom_node { my ($class, $node, $config) = @_; if ($node->nodeType == XML_TEXT_NODE) { - $config->{content} = $node->textContent; + $config->{_content} = $node->textContent; } elsif ($node->nodeType == XML_ELEMENT_NODE) { my $subconfig = {}; @@ -239,9 +239,9 @@ sub _read_from_dom_node { delete $subconfig->{id}; } else { my @keys = keys %$subconfig; - if (1 == scalar @keys && $keys[0] eq 'content') { + if (1 == scalar @keys && $keys[0] eq '_content') { # An element with no attributes and no child elements becomes its text content - $subconfig = $subconfig->{content}; + $subconfig = $subconfig->{_content}; } elsif (0 == scalar @keys) { # An empty element becomes an empty string $subconfig = ''; -- 2.30.2