diff --git a/PgCommon.pm b/PgCommon.pm
index 56769df0dbb18c04ba678bc23cd6b04afbb26d43..780bde9d83d92a2a4f6ff4c0b7178e539eb562b4 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 ea67f7f3a8acc853f36bdf5e973a97a5095bdcbd..7799053278d571247dbe15b382a8eaade191f275 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 b34c77764941f42e7ad7f044dd62f55fdcbf4fa3..fef5330029d17aabfd60188d632ed75a0246ed1d 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;