From e1a35ab6e31aeefbfb18d9ce9f9c239da75fd2bf Mon Sep 17 00:00:00 2001
From: Christoph Berg <myon@debian.org>
Date: Sun, 28 Jan 2018 19:29:03 +0100
Subject: [PATCH] PgCommon.pm: Fix include directives parser, spotted by
 ironhalik, thanks!

---
 PgCommon.pm      | 4 ++--
 debian/changelog | 1 +
 t/005_PgCommon.t | 8 ++++----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/PgCommon.pm b/PgCommon.pm
index 56769df0..780bde9d 100644
--- a/PgCommon.pm
+++ b/PgCommon.pm
@@ -131,7 +131,7 @@ sub read_conf_file {
         while (<F>) {
             if (/^\s*(?:#.*)?$/) {
                 next;
-            } elsif(/^\s*include_dir\s+'([^']+)'\s*$/i) {
+            } elsif(/^\s*include_dir\s*=?\s*'([^']+)'\s*(?:#.*)?$/i) {
                 # read included configuration directory and merge into %conf
                 # files in the directory will be read in ascending order
                 my $path = $1;
@@ -147,7 +147,7 @@ sub read_conf_file {
                     }
                 }
                 closedir($dir);
-            } elsif (/^\s*include(?:_if_exists)?\s+'([^']+)'\s*$/i) {
+            } elsif (/^\s*include(?:_if_exists)?\s*=?\s*'([^']+)'\s*(?:#.*)?$/i) {
                 # read included file and merge into %conf
                 my $path = $1;
                 my $absolute_path = get_absolute_path($path, $config_path);
diff --git a/debian/changelog b/debian/changelog
index ea67f7f3..77990532 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,7 @@ postgresql-common (190) UNRELEASED; urgency=medium
   * pg_virtualenv: Error out if no server packages are installed.
   * postgresql-common recommends e2fsprogs, we are using chattr in
     pg_createcluster. (Closes: #887251)
+  * PgCommon.pm: Fix include directives parser, spotted by ironhalik, thanks!
 
  -- Christoph Berg <myon@debian.org>  Mon, 25 Dec 2017 18:03:38 +0100
 
diff --git a/t/005_PgCommon.t b/t/005_PgCommon.t
index b34c7776..fef53300 100644
--- a/t/005_PgCommon.t
+++ b/t/005_PgCommon.t
@@ -142,18 +142,18 @@ print F <<EOF;
 # commented_str = 'notme'
 
 intval = -1
-include '8.4/test/foo.conf'
-include_dir 'conf.d'
+include '8.4/test/foo.conf' # foo
+include_dir 'conf.d' # bar
 strval = 'howdy'
 include_if_exists '/nonexisting.conf'
-include_if_exists '8.4/test/condinc.conf'
+include_if_exists = '8.4/test/condinc.conf'
 EOF
 close F;
 
 open F, ">$tdir/conf.d/sub.conf" or die "Could not create $tdir/conf.d/sub.conf: $!";
 print F <<EOF;
 subvalue = 1
-include '../relative.conf'
+include = '../relative.conf'
 EOF
 close F;
 
-- 
GitLab