From 0b743b00d1639de6d7056360925e3602d500541e Mon Sep 17 00:00:00 2001
From: Fabien Combernous <fabien.combernous@adullact.org>
Date: Mon, 13 May 2019 23:16:33 +0200
Subject: [PATCH] Resolve "space and double quote can be present in wp fields"

---
 README.md                                | 4 +++-
 metadata.json                            | 2 +-
 templates/external_fact_wordpress.rb.erb | 6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 6580ab7..30e4b99 100644
--- a/README.md
+++ b/README.md
@@ -257,7 +257,6 @@ Details in `REFERENCE.md`.
 This module is tested with following OSes :
   * Ubuntu 16.04
   * Debian 8, 9
-  * CentOS 7
 
 Known bugs are listed in `CHANGELOG.md` file.
 
@@ -265,6 +264,9 @@ Even if module should work with Puppet4, Puppet 4 is end of life since 2019-01-0
 So tests with Puppet 4 are removed.
 Acceptance tests are done with last available release 5 and 6.
 
+PHP shiped with CentOS 7 is version 5.4. WordPress 5.2 requires at least 5.6.20.
+So, CentOS7 is removed from acceptance tests and from the list of compatible OSes.
+
 ## Development
 
 Home at URL https://gitlab.adullact.net/adullact/puppet-wordpress
diff --git a/metadata.json b/metadata.json
index b158267..bc92f06 100644
--- a/metadata.json
+++ b/metadata.json
@@ -47,4 +47,4 @@
   "pdk-version": "1.9.1",
   "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
   "template-ref": "1.9.1-0-g6945d31"
-}
\ No newline at end of file
+}
diff --git a/templates/external_fact_wordpress.rb.erb b/templates/external_fact_wordpress.rb.erb
index 9a3471b..c6cebe1 100755
--- a/templates/external_fact_wordpress.rb.erb
+++ b/templates/external_fact_wordpress.rb.erb
@@ -68,7 +68,7 @@ for site in wproot.keys
   Open3.popen3('wp','--allow-root','--format=csv',"--path=#{path}",'--fields=language,status,update','--status=active','language','core','list') do |stdin, stdout, stderr, wait_thr|
     if wait_thr.value.success?
       while line = stdout.gets
-        langcode, langstatus, langupdate = line.match(/^([\w_]+),([\w]+),([\w]+)/).captures
+        langcode, langstatus, langupdate = line.match(/^([\w_]+),(["\w ]+),(["\w ]+)/).captures
 
         lang_hash = {}
         if langcode != 'language'
@@ -90,7 +90,7 @@ for site in wproot.keys
   Open3.popen3('wp','--allow-root','--format=csv',"--path=#{path}",'plugin','list') do |stdin, stdout, stderr, wait_thr|
     if wait_thr.value.success?
       while line = stdout.gets
-        pluginname, pluginstatus, pluginupdate, pluginversion = line.match(/^([\w\d-]+),([\w\d]+),([\w\d]+),([\w\d\.]+)/).captures
+        pluginname, pluginstatus, pluginupdate, pluginversion = line.match(/^([\w\d-]+),(["\w\d ]+),(["\w\d ]+),(["\w\d\. ]+)/).captures
 
         plugin_hash = {}
         if pluginname != 'name'
@@ -112,7 +112,7 @@ for site in wproot.keys
   Open3.popen3('wp','--allow-root','--format=csv',"--path=#{path}",'theme','list') do |stdin, stdout, stderr, wait_thr|
     if wait_thr.value.success?
       while line = stdout.gets
-        themename, themestatus, themeupdate, themeversion = line.match(/^([\w\d-]+),([\w\d]+),([\w\d]+),([\w\d\.]+)/).captures
+        themename, themestatus, themeupdate, themeversion = line.match(/^([\w\d-]+),(["\w\d ]+),(["\w\d ]+),(["\w\d\. ]+)/).captures
 
         theme_hash = {}
         if themename != 'name'
-- 
GitLab